I have used Matplotlib to plot lines on a figure. Now I would now like to set the style, specifically the marker, for individual points on the line. How do I do this?
To clarify my question, I want to be able to set the style for individual markers on a line, not every marker on said line.
Best Answer
Specify the keyword args
linestyle
and/ormarker
in your call toplot
.For example, using a dashed line and blue circle markers:
A shortcut call for the same thing:
Here is a list of the possible line and marker styles:
edit: with an example of marking an arbitrary subset of points, as requested in the comments:
This last example using the
markevery
kwarg is possible in since 1.4+, due to the merge of this feature branch. If you are stuck on an older version of matplotlib, you can still achieve the result by overlaying a scatterplot on the line plot. See the edit history for more details.