← 返回首页
legends, part 1 by kushalkolar · Pull Request #406 · fastplotlib/fastplotlib · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

legends, part 1#406

Merged
kushalkolar merged 25 commits into
mainfrom
legends
Feb 29, 2024
Merged

legends, part 1#406
kushalkolar merged 25 commits into
mainfrom
legends

Conversation

kushalkolar commented Feb 19, 2024
edited
Loading

Copy link
Copy Markdown
Member

starts #403

major WIP

kushalkolar mentioned this pull request Feb 19, 2024

kushalkolar commented Feb 20, 2024
edited
Loading

Copy link
Copy Markdown
Member Author

got some very basic stuff working, can add simple LineGraphics to the legend

Changing label and auto-update of colors and thickness works

Copy link
Copy Markdown
Member Author

I should determine a way to make a sorting method for LegendItems in space (based on the size of each) and then organize into an optimal column, row or grid of items. Get the bbox for all LegendItems and set the Legend mesh to the bbox.

Copy link
Copy Markdown
Member Author

If legend is placed in the main plot area scale the text size and spacing based on current scene bbox.

kushalkolar changed the title legends legends, part 1 Feb 27, 2024
kushalkolar marked this pull request as ready for review February 27, 2024 05:22

clewis7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Is there a plan to have something like plot.add_legend(), that would take a plot_area and auto generate a legend based on existing graphics in the plot?

Notes:

  1. Interesting functionality, if I don't specify a dock to put the legend in, it places it in the middle of the plot. Should we have a default dock to use ("top" or "right") if someone just passes the plot?
  2. Also, if I don't change the size of the dock before adding the legend, it doesn't appear? Should we automatically change the size of the dock area that the legend is being added to?
  3. Legend location: it appears like the legend is not centered in the middle of the plot.

Comment thread fastplotlib/layouts/_plot_area.py Show resolved Hide resolved
Comment thread fastplotlib/legends/legend.py Show resolved Hide resolved

clewis7 commented Feb 28, 2024

Copy link
Copy Markdown
Member

I see here you provided images exemplifying use, I think we should add a legends.ipynb.

@kushalkolar thoughts?

clewis7 commented Feb 28, 2024

Copy link
Copy Markdown
Member

Interesting functionality, if I don't specify a dock to put the legend in, it places it in the middle of the plot. Should we have a default dock to use ("top" or "right") if someone just passes the plot?

I see you can pass a Plot, Dock, or Subplot. My only worry is that when I just passed the same plot that my data is in it put the legend over the graphic. Guess maybe it is up to the user to know that you can put legend in a plot or subplot by itself, or you can put it in a dock.

Comment thread fastplotlib/legends/legend.py Show resolved Hide resolved
Comment thread fastplotlib/legends/legend.py Show resolved Hide resolved

Copy link
Copy Markdown
Member Author

Is there a plan to have something like plot.add_legend(), that would take a plot_area and auto generate a legend based on existing graphics in the plot?

We can think about this later once we have all the legend functionality we want.

  1. Interesting functionality, if I don't specify a dock to put the legend in, it places it in the middle of the plot. Should we have a default dock to use ("top" or "right") if someone just passes the plot?

Nope, it can make sense to put the legend in the main plot area too, the user can move them out of the way of existing graphics if required.

  1. Also, if I don't change the size of the dock before adding the legend, it doesn't appear? Should we automatically change the size of the dock area that the legend is being added to?

Done

  1. Legend location: it appears like the legend is not centered in the middle of the plot.

We can fix this later XD

I see here you provided images exemplifying use, I think we should add a legends.ipynb.

We can do this after implementing all legend functionality that we want, basically when we fully resolve #403

it is up to the user to know that you can put legend in a plot or subplot by itself, or you can put it in a dock.

Yup!

kushalkolar merged commit 8919d7c into main Feb 29, 2024
kushalkolar deleted the legends branch March 4, 2024 12:17

Copy link
Copy Markdown
Member Author

Is there a plan to have something like plot.add_legend(),

Now after the recent References refactor I realize this is probably the best way to do it, keep the API uniform. Can properly look into it after or during axes.

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
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.

2 participants

Footer

© 2026 GitHub, Inc.