Ganesh
Ganesh

Reputation: 23

Is it possible to reduce no of markers in a matplotlib plot?

I have a fitted distribution curve where I would like to reduce no. of markers.

Can anyone suggest tricks to do that?

Upvotes: 2

Views: 3554

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339240

The plot command has an argument markevery.

markevery [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]

This is a bit cryptic, but there is an example on the matplotlib page, showing different ways to use this argument.

Quoting from the example's text:

Integer arguments are fairly intuitive. e.g. markevery=5 will plot every 5th marker starting from the first data point.
Float arguments allow markers to be spaced at approximately equal distances along the line. The theoretical distance along the line between markers is determined by multiplying the display-coordinate distance of the axes bounding-box diagonal by the value of markevery. The data points closest to the theoretical distances will be shown.

So for a simple example case, use

plt.plot(x,y, marker="o", markevery=5)

to plot every 5th marker only.

Upvotes: 5

Related Questions