I have a loop where i create some plots and I need unique marker for each plot. I think about creating function, which returns random symbol, and use it in my program in this way:
for i in xrange(len(y)):
plt.plot(x, y [i], randomMarker())
but I think this way is not good one. I need this just to distinguish plots on legend, because plots must be not connected with lines, they must be just sets of dots.
It appears that nobody has mentioned the built-in pyplot method for cycling properties yet. So here it is:
However, this way you lose the color cycle. You can add back color by multiplying a color
cycler
and a markercycler
object, like this:itertools.cycle
will iterate over a list or tuple indefinitely. This is preferable to a function which randomly picks markers for you.Python 2.x
Python 3.x
You can use that to produce a plot like this (Python 2.x):
You can also use marker generation by tuple e.g. as
See Matplotlib markers doc site for details.
In addition, this can be combined with itertools.cycle looping mentioned above
Just manually create an array that contains marker characters and use that, e.g.: