Skip to content

Variable spacing of markers for 2D line plot #2523

@jman87

Description

@jman87

I have been searching for a way to make a 2D line plot where the lines have markers, but the markers are not placed on every single data point but are placed at some user-defined interval.

If anyone has ever used the program Dplot www.dplot.com you'll know this is a very useful feature when plotting large data sets with thousands of points. The need for markers arises often as many journals still require that plots be understandable when printed in black & white. When you have a lot of curves the dash linestyles are often not enough and markers are needed, but if they get plotted on every point it makes the plot garbage.

As an example, I'm wanting a way to make something that looks similar to the figure below. The way I created it is really clunky though, and the legend is not really correct because only the marker is shown and the line is missing. I made this plot by sequentially plotting the sin(x) function as a line over a 101 x points and then plotting the markers over only 11 x points. I set the linewidth=0 for the line so that I wouldn't have duplicate entries in the legend. But again, the legend is not the way we would want it as it's missing the line.

sin_x_plot

If someone knows a way to do this I'd be very happy to hear it - even if it's a hack for the time being. But hopefully everyone will see the merit of this and make it a basic feature.

FYI, my preferred backend is plotlyjs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions