Skip to content
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

Add legends #2

Open
milliams opened this issue Mar 2, 2018 · 1 comment
Open

Add legends #2

milliams opened this issue Mar 2, 2018 · 1 comment

Comments

@milliams
Copy link
Owner

milliams commented Mar 2, 2018

We should be able to collect the objects being plotted and create a legend. We need to know:

  • What objects are plotted
  • How to draw an icon for each
  • Where to put the legend by default
@Ploppz
Copy link
Contributor

Ploppz commented Feb 18, 2019

I made a first draft here.
I added legend_svg() to trait ContinuousRepr and implemented it for Line (for now). It uses the Line's LineStyle to determine and draw the icon it should use.
Then, in <ContinuousView as View>::to_svg(), when we loop through the representations we also get their legends, and place them under each other in the top right corner.

Edit: parts of the implementation were apparently in previous commits. For example a way to set the legend in Line: https://github.com/Ploppz/plotlib/blob/wip/src/repr/line.rs#L44

Questions and possible changes:

  • Maybe legend_svg should also be a function in the different styles, so that Function::legend_svg and Line::legend_svg can both use LineStyle::legend_svg?
  • Make the position of the legends adapt to what is plotted (so that it doesn't collide)?
    • and/or: Make it possible for the user to select the position: one of the corners, and maybe even outside of the plot (I think matplotlib allows this)

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

No branches or pull requests

2 participants