Skip to content

Add optional legend title #105

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add optional legend title #105

wants to merge 3 commits into from

Conversation

bircni
Copy link
Contributor

@bircni bircni commented May 4, 2025

This pull request introduces enhancements to the Legend functionality in the egui_plot library, updates the plot demos to include legend titles, and modifies related tests and snapshots to reflect these changes. The most significant changes include adding a title property to the Legend struct, updating plot demos to utilize this new feature, and adjusting test infrastructure and snapshots accordingly.

Enhancements to Legend functionality:

  • egui_plot/src/legend.rs: Added a title property to the Legend struct, with a default value of None. Introduced a new title method to set the legend title and updated the LegendWidget to display the title if it is set. [1] [2] [3] [4]

Updates to plot demos:

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Looks good, but the title should always be on top

@@ -46,6 +46,7 @@ pub struct Legend {
pub text_style: TextStyle,
pub background_alpha: f32,
pub position: Corner,
pub title: Option<String>,
Copy link
Owner

Choose a reason for hiding this comment

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

This could use WidgetText instead for more customizability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't work as WidgetText does not implement serde - we could do this here too but i dont know if that is good

@emilk emilk changed the title add legend title Add optional legend title Jun 16, 2025
@bircni
Copy link
Contributor Author

bircni commented Jun 16, 2025

when we update to the newer egui main we can use PixelThreshold so these tests dont fail anymore
@emilk

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.

Title (or label) for legend.
2 participants