Skip to content

[legend pt4] Plot+legend picts - #73

Closed
bdeket wants to merge 1 commit into
racket:masterfrom
bdeket:plot+legend-picts
Closed

bdeket wants to merge 1 commit into
racket:masterfrom
bdeket:plot+legend-picts

Conversation

@bdeket

@bdeket bdeket commented Sep 10, 2020

Copy link
Copy Markdown
Contributor

allow plotting plot and legend to two different picts as was the original question in #49

allow plotting plot and legend to two different picts

@alex-hhh alex-hhh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added some practical commends about the pull request, and I will merge it once they are addressed, however, I am a concerned about the entire idea of providing the plot legend as a picture.

I know this was requested in the original issue, but the forum discussions requested just placing the legend outside the plot area, and the idea of having the legend as a pict was the idea of a single person and I feel it was not discussed enough.

I am not sure that anyone would use this feature, so it is very difficult to determine if we provided the right thing. And we have limited opportunity to correct things once they are published in a Racket release, as the plot package needs to be backwards compatible forever.

However, placing the legend outside the plot area is a feature that is available in other plot libraries and we can be more certain that we provided the right (or at least a workable) interface...

(define legend (get-legend-entry-list renderer-list bounds-rect))

(define-values (width height)
(parameterize/group ([plot-parameters saved-values])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need parameterize/group here -- this code runs in the same thread that captured the parameters.

[#:x-min (U Real #f) #:x-max (U Real #f)
#:y-min (U Real #f) #:y-max (U Real #f)]
Pict))
(define (legend-pict renderer-tree

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name legend-pict is a bit confusing (in my opinion anyway). I think plot-legend-as-pict would be a better option, but perhaps there are other possibilities?

I also feel that using the x-min ... arguments is a bit counter-intuitive, but I understand why it is necessary.

(send pd restore-drawing-params)))
width height)]))

(:: plot+legend-picts

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function is necessary, as it does not provide any more functionality than calling plot-pict and legend-pict separately, and I would prefer to keep the new API functions to a minimum

[#:x-min (U Real #f) #:x-max (U Real #f)
#:y-min (U Real #f) #:y-max (U Real #f)]
Pict))
(define (legend3d-pict renderer-tree

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about the naming, perhaps plot3d-legend-as-pict?

#:x-label (U String pict #f)
#:y-label (U String pict #f)]
(Values Pict Pict)))
(define (plot+legend3d-picts renderer-tree

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as for 2D plots -- I don't think this function is necessary

@bdeket

bdeket commented Sep 19, 2020

Copy link
Copy Markdown
Contributor Author

I don't mind not introducing this, as I prefer to have the legend in the plot. But if we do, I think the better option is the one where plot+legend are provided, so at least the #:x-min etc arguments make more sense. Feel free to close this PR.

@alex-hhh

Copy link
Copy Markdown
Collaborator

Unless someone has a concrete use case for this, as opposed to just brainstorming some possible use cases, we can easily add it in, given all the refactoring that was done. However, once we add something to the plot package API, it will need to be maintained practically forever, so I am hesitant to add things for "just in case" scenarios, because we might implement them to support only limited use cases so they have the potential to be useless to most of the users.

Also note, that users can also create manual legends using picts, although perhaps a bit inconvenient, but with a lot of flexibilities, this was illustrated in the google-groups discussion listed from #49.

@alex-hhh alex-hhh closed this Sep 21, 2020
@bdeket
bdeket deleted the plot+legend-picts branch September 22, 2020 15:00
@bdeket
bdeket restored the plot+legend-picts branch October 10, 2020 14:53
@bdeket
bdeket deleted the plot+legend-picts branch October 10, 2020 15:14
@Metaxal

Metaxal commented Jan 28, 2022 •

Copy link
Copy Markdown

I'd like to try this change, but the branch has been deleted and the git apply patch 73.patch fails with patch does not apply (after downloading the patch file).

I could copy/paste the code manually, but I'd rather avoid as I expect complications. Can the branch be restored, or is there another way I can patch this?

@bdeket

bdeket commented Jan 28, 2022

Copy link
Copy Markdown
Contributor Author

I deleted this branch on all my devices. It seems github gives me an option to "restore branch", but I don't know if it will work.
One thing to keep in mind with these patches for the legend: there where a bunch of them at the same time that were interconnected. And after dropping this branch updates for the other branches where not incorporated into this one.
I guess the best thing to first try is reverting to commit e97c8e7 or somewhere thereabout and see if at this point the patch still works.

@bdeket
bdeket restored the plot+legend-picts branch January 28, 2022 18:10
@Metaxal

Metaxal commented Jan 30, 2022

Copy link
Copy Markdown

Quickly: I could eventually patch it on top of HEAD (sorry, just saw you restored the branch), and it works fine with ht-append but weirdly offsets the legend by the plot amount with hc-append, and double that with hb-append. This can be fixed by using freeze on the legend first, but it shouldn't be the case I think.

I'll get back to this soon, hopefully.

Thanks for starting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants