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

Plotting: Add line markers #362

Closed
EmbersArc opened this issue May 9, 2021 · 5 comments · Fixed by #363
Closed

Plotting: Add line markers #362

EmbersArc opened this issue May 9, 2021 · 5 comments · Fixed by #363
Labels
feature New feature or request

Comments

@EmbersArc
Copy link
Contributor

It would be great to have line markers for curves in the plotting library. It's mostly done but there are still some open questions that I'll have to figure out when it comes to user friendliness. I'll open a draft PR soon.

image

@EmbersArc EmbersArc added the feature New feature or request label May 9, 2021
@emilk
Copy link
Owner

emilk commented May 9, 2021

Can I ask what this is for?

I thought line markers were used mostly when printing plots in black-and-white. Is there really a need for it in a full-color interactive plot? And if there is a need for something like this, isn't dashed and dotted lines more readable?

@EmbersArc
Copy link
Contributor Author

The initial idea was to add scatter plots (no lines, only points). But those share all the functionality with the Curve datatype we currently have, and only really differ in appearance. So I did not want to create a separate datatype just for that. This is an attempt to unify those so that curves can also be used as scatter plots. I'm also making the markers very configurable, so something like this is possible as well:
image
This is important when working with real data and you want to show where the actual datapoints are.

I hope this makes sense, you can have a look at the draft PR to see how it's implemented right now. Maybe you even have a better idea.

@emilk
Copy link
Owner

emilk commented May 9, 2021

Showing the data points as dots makes sense, and supporting scatter plots makes sense as well. It's the choice of using symbols (stars, triangles, …) over colored dots that gets me a bit hesitant. One could argue the the former is better for the color blind, but interactive plots which can highlight on hover makes this much less of a problem already.

@skairunner
Copy link

skairunner commented May 11, 2021

Using symbols on line charts is pretty common in the infoviz world, I think. It's recommended over colored dots precisely because of readability. Uglier for sure, though, which is why it'd be nice to support either method. Maybe if the markers could take on the color of the line?

@EmbersArc
Copy link
Contributor Author

Based on experience, I can confirm that it's sometimes very useful to have a small selection of marker shapes to choose from. They may have different meanings in the plot and then it could be confusing to only have dfiferent colored dots. But I understand your concerns @emilk so I took some time to figure out how to keep functionality simple while still making different marker shapes available. Now, you can add a default marker to the plot like this:

        Curve::from_parametric_callback(
            move |t| ((2.0 * t + time).sin(), (3.0 * t).sin()),
            0.0..=TAU,
            100,
        )
        .color(Color32::from_rgb(100, 150, 250))
        .marker(Marker::default())
        .name("x = sin(2t), y = sin(3t)")

This will add filled dots to the datapoints with the same color as the line, as suggested by @skairunner as well. But they can be customized further (within reason) like this:

curve.marker(marker.filled(false).radius(5.0).color(Color32::GRAY))

I extended the plot demo a bit so that we can showcase this:

recording.mp4

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

Successfully merging a pull request may close this issue.

3 participants