Skip to content

Marker markerlinewidth#1690

Merged
swharden merged 20 commits intoScottPlot:masterfrom
BambOoxX:marker-markerlinewidth
Feb 23, 2022
Merged

Marker markerlinewidth#1690
swharden merged 20 commits intoScottPlot:masterfrom
BambOoxX:marker-markerlinewidth

Conversation

@BambOoxX
Copy link
Contributor

This PR implements a MarkerLineWidth property and subsequent modifications to allow to change the stroke width of a marker.

This is still a WIP.

Commit cea4994 breaks the legend for pie chart and maybe other plot types.
This might be the occasion to create a IHasArea interface handling all plots that are related (visually at least) to an area / surface with respect to IHasLine. This would avoid to use the isRectangle property in Legend.

Here is how looks the "All Markers" example with the new capabilities and sp.LineWidth = 2 --> sp.LineWidth = i;

image

@BambOoxX

This comment was marked as resolved.

@BambOoxX

This comment was marked as resolved.

@swharden
Copy link
Member

swharden commented Feb 23, 2022

Hi @BambOoxX,

I think I'm mostly done reviewing this PR but can you help me understand the intent behind this modifications to scatter plots?

public double LineWidth
{
    get => IsHighlighted ? _lineWidth * HighlightCoefficient : _lineWidth;
    set { _lineWidth = value; _markerLineWidth = (float)value / 2; _markerSize = (float)value * 2; }
}

It seems a little strange to me that changing the LineWidth (part of IHasLine) will secretly change MarkerLineWidth (part of IHasMarker). I'm going to remove that part of the setter, but let me know if there's a good reason for it to be there and I may put it back 👍

EDIT: I'm going to merge but feel free to continue the discussion here or open a new PR if you have suggestions

@swharden
Copy link
Member

This landed in an awesome spot, thanks so much @BambOoxX!

image

var plt = new ScottPlot.Plot();

double[] ys1 = DataGen.Sin(30);
var cmap1 = ScottPlot.Drawing.Colormap.Viridis;

double[] ys2 = DataGen.Cos(30);
var cmap2 = ScottPlot.Drawing.Colormap.Turbo;

for (int i = 0; i < ys1.Length; i++)
{
    double frac = i / (ys1.Length - 1f);

    var circle = plt.AddMarker(i, ys1[i]);
    circle.MarkerShape = MarkerShape.openCircle;
    circle.MarkerSize = i + 5;
    circle.MarkerLineWidth = 1 + i / 2;
    circle.MarkerColor = cmap1.GetColor(1 - frac, .8);

    var triangle = plt.AddMarker(i, ys2[i]);
    triangle.MarkerShape = MarkerShape.openTriangleUp;
    triangle.MarkerSize = i + 5;
    triangle.MarkerLineWidth = 1 + i / 4;
    triangle.MarkerColor = cmap2.GetColor(frac, .8);
}

@swharden swharden merged commit 9696382 into ScottPlot:master Feb 23, 2022
@BambOoxX
Copy link
Contributor Author

The idea behind changing the marker properties when changing the line width is only to preserve consistency. The main point is that if you draw a thick line to make it very visible, ans that it has markers, you probably want to see the markers pretty well too.
But that feature is really not mandatory

In a more marker-centric context, it could be interesting that setting the marker size sets the marker line width because large markers with thin lines look correct but small markers with thick lines are very distorded

@BambOoxX BambOoxX deleted the marker-markerlinewidth branch February 23, 2022 08:58
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