Repository navigation
[Legend pt3] Make legend available to area at start #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1f1b79a
legend: early calculation of the legend
bdeket 4b4d1d4
legend: fix for tests
bdeket 5aaedaf
legend: remove unused code
bdeket a479294
legend: change type for plot
bdeket fa1361d
legend: fix anchor and outside bounds
bdeket 3f91329
legend: fix untyped contract
bdeket a36f58d
legend: change fct name get-legend-entry-list
bdeket File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand your choice for defining the
legend-anchor/ccontract andLegend-Anchortype. I don't understand what the#fvalue is for, and the list definition produces values which don't make sense to me. E.g. where would the legend be placed when the anchor is(outside center)? Also, theinsideentries overlap with the plain one (e.g.(inside top)is the same astop?)My thought was to make the legend anchor values a type completely independent from
anchor/c, some symbols are common, with some additional ones:This would allow placing the legend to the left or right of the plot area. I am not sure that it is worth adding legends at the top and bottom of the plot, did you intend to add that feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#f: This allows to not print the legend at all. Which makes it easy to implement the original question of legend outside the plot area (return legend as pict?) #49. You now can create a render tree. Pass it to a function that will extract the legend, and later pass this render tree to a plot function (with#fas legend anchor) and only plot it without the legend.'(outside top/bottom): if the legend is only one item, the legend will be much wider than high. Being able to print it at the top or bottom will reduce the space lost for the actual plot. And it looks better in the top-center than the top-left. So yes this was an intended addition. Especially thinking about a future parameter that allows a horizontal layout for the legend.'(inside anchor/c)is indeed equivalent withanchor/c. When I started I was thinking it might make sense to instead of an anchor, pass coordinates to place it at an exact position. In the end I didn't go further with this.In general:
'(outside ...)means it's drawn together with the title, before anything else, and (inside ...) means it's drawn after all other plot items, so indeed'(outside center)makes less sense since it will result in a legend in the middle of the width/height of the plot, but below all other drawn items. Whereas'(inside center)will result in a legend in the middle of the area-width/area-height of the plot, and above al other items.Also: according to the documentation anchor/c should allow
'auto, which it doesn't, and use'bottom-leftfor things that are not a text-label, whereas the legend implementation uses'top-left.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'autois used for renders such aspoint-label, to select an anchor which ensures that the entire label fits inside the plot area, the value does not make sense for the legend, and I forgot to add the documentation. There is also a confusion that theanchor/ccontract is not actually used for thepoint-labeland related functions, since they are exported directly from Typed-Racket with the Anchor type -- by the way I use this parameter a lot in my own programs.the
#fcase is indeed something I did not thing about, but you are correct that we need it if we want to render the legend as a separate pict. Until now, if the user did not want a legend, they could just not provide a#:labelentry for any of their renderers.also, your explanation for
'insideand'outsidemakes sense -- I didn't think about all the possible cases. Leave them as they are, and we see if they need changing.BTW, I think we should add a todo list on #49 for all the small things that we find, to get to them later. I will add a note about the missing
'autodocumentation as well as the note about not beginning the plot when there are no renderers.