Skip to content

Legend: default marker style#5006

Merged
swharden merged 6 commits intoScottPlot:mainfrom
aespitia:feature/aespitia/set-legend-markerStyle-default
Aug 8, 2025
Merged

Legend: default marker style#5006
swharden merged 6 commits intoScottPlot:mainfrom
aespitia:feature/aespitia/set-legend-markerStyle-default

Conversation

@aespitia
Copy link
Contributor

This is to hopefully implement a default marker type, in case you want to keep all of legend defaults, but change the marker style. Looking for feedback from @swharden or anyone else familiar with the Legend/LegendItems, but hopefully fixes issue #5005

I included a new cookbook item for Legend > Default Marker style

ScottPlot.Plot myPlot = new();
var sig1 = myPlot.Add.Signal(Generate.Sin(51));
sig1.LegendText = "Sin";

var sig2 = myPlot.Add.Signal(Generate.Cos(51));
sig2.LegendText = "Cos";

myPlot.Legend.MarkerShapeDefault = MarkerShape.FilledCircle;


LegendItem item1 = new()
{
    MarkerColor = Colors.Red,
    MarkerShape = MarkerShape.Cross,
    LabelText = "Alpha"
};

LegendItem item2 = new()
{
    MarkerColor = Colors.Green,
    MarkerShape = MarkerShape.FilledSquare,
    LabelText = "Beta"
};

myPlot.Legend.ManualItems.Add(item1);
myPlot.Legend.ManualItems.Add(item2);

myPlot.ShowLegend();
image

@swharden
Copy link
Member

wow, that was fast @aespitia, thanks so much!

Do you think we should roll changes from #4893 into this PR too and merge it all at once? I haven't done a thorough review yet, but adding underline support seems closely related and I'm not sure whether these branches would cause merge conflicts or perhaps if you'd be a good person to consolidate these different PRs into this one because you have the finger on the pulse of what our emerging API is for font styling.

I'm about to head out camping for several days, but I'll be back Monday and can take a closer look after that! It's at Anastasia State Park in Florida with 100F/38C heat so it'll be quite an experience lol

Thanks again for all your help on this! I really appreciate all the heavy lifting you do with these complex PRs and nuanced topics 🚀

@aespitia
Copy link
Contributor Author

aespitia commented Jul 31, 2025

wow, that was fast @aespitia, thanks so much!

Do you think we should roll changes from #4893 into this PR too and merge it all at once? I haven't done a thorough review yet, but adding underline support seems closely related and I'm not sure whether these branches would cause merge conflicts or perhaps if you'd be a good person to consolidate these different PRs into this one because you have the finger on the pulse of what our emerging API is for font styling.

I'm about to head out camping for several days, but I'll be back Monday and can take a closer look after that! It's at Anastasia State Park in Florida with 100F/38C heat so it'll be quite an experience lol

Thanks again for all your help on this! I really appreciate all the heavy lifting you do with these complex PRs and nuanced topics 🚀

I think this particular PR is a little different, this one is about legend markers, I had this PR in before the Font Resolver PR, however, I think the #4893 underline changes can probably be merged into the font one, I can make another local branch and do a test merge to see if I run into any conflicts, but it might go in clean.

Also, have fun camping in this heat, I'm in NC, and it's not been fun outside for the last few weeks lol. stay hydrated!

@aespitia
Copy link
Contributor Author

aespitia commented Jul 31, 2025

@swharden I locally did a test merge with the Underline branch + this Marker branch and separately did the Underline + the Font branch and did not run into any merge conflicts with either one, so they should all be able to be merged cleanly

@swharden
Copy link
Member

swharden commented Aug 8, 2025

should all be able to be merged cleanly

Thanks for looking into it! I just merged and it was super easy 😎

camping in this heat

It was fun, but not gonna challenge that in July again lol 🔥

@swharden swharden enabled auto-merge (squash) August 8, 2025 00:21
@swharden swharden changed the title feat: adding a new parameter to set a default marker style Legend: default marker style Aug 8, 2025
@swharden swharden merged commit 87e5471 into ScottPlot:main Aug 8, 2025
3 checks passed
@aespitia aespitia deleted the feature/aespitia/set-legend-markerStyle-default branch August 8, 2025 13:23
@manaruto
Copy link
Contributor

manaruto commented Aug 9, 2025

Hi @aespitia

I have recently opened a new pull request that builds upon the changes made here.
My PR addresses a regression introduced after this one, MarkerStyle.Size stopped taking effect when MarkerShapeDefault was set and also fixes the marker clipping issue.

It would be great if you could take a look at my changes to ensure they don’t conflict with the intent of your original fix. I tried to preserve the functionality you introduced while resolving the size and clipping issues.

Thanks in advance

@aespitia
Copy link
Contributor Author

Hi @aespitia

I have recently opened a new pull request that builds upon the changes made here. My PR addresses a regression introduced after this one, MarkerStyle.Size stopped taking effect when MarkerShapeDefault was set and also fixes the marker clipping issue.

It would be great if you could take a look at my changes to ensure they don’t conflict with the intent of your original fix. I tried to preserve the functionality you introduced while resolving the size and clipping issues.

Thanks in advance

I pulled your branch and the recipe i added still works, I like it, thanks for taking a look. I wasn't sure what was going on in there, which is why I left that note in there, but it had fixed an existing bug anyway where some of the legend items were using the wrong marker anyway. thanks again!

@swharden
Copy link
Member

Quick update, signal plots now show large circle markers

image

I think the issue is here. I'll try to get a quick fix in by editing #5048

item.MarkerStyle.Shape = item.MarkerShape;
// If the marker size is not set, use the label font size as a fallback
//NOTE: Same as above, tried it, but somehow the default is really small, setting to font size for now.
//item.MarkerStyle.Size = item.MarkerStyle.Shape != MarkerShape.None && item.MarkerStyle.Size != 0? item.MarkerStyle.Size : item.LabelFontSize;
item.MarkerStyle.Size = item.LabelFontSize;
if (item.MarkerShape == MarkerShape.None && item.MarkerStyle.Shape == MarkerShape.None)
{
item.LineStyle.Render(canvas, symbolLine, paint);
}
item.FillStyle.Render(canvas, symbolFillRect, paint);
item.OutlineStyle.Render(canvas, symbolFillOutlineRect, paint);

swharden added a commit that referenced this pull request Aug 17, 2025
swharden added a commit that referenced this pull request Aug 17, 2025
* Fonts.Reset()

* Legend: improve default marker styling

extends #5006

* Radar: use new polar plot rotation features
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