When I plot three lines in one go, matplotlib samples through three steps of the current cycler, giving each its own style:
In [11]: x = linspace(0, 5, 50)
In [12]: y = vstack([x**2, x**3, x**4]).T
In [13]: plot(x, y)
Out[13]:
[<matplotlib.lines.Line2D at 0x7edfa9144550>,
<matplotlib.lines.Line2D at 0x7edfa9144b38>,
<matplotlib.lines.Line2D at 0x7edfa9144cf8>]
I can make them all the same color with plot(x, y, color="black")
. However, I don't want them all black; I want that each of the lines respects the current (next) state of the cycle.
Getting the current state is cumbersome at best. I could expand x
and flatten y
to get all three with the same style:
In [54]: plot(vstack([x]*3).ravel(), y.T.ravel())
but this will create a spurious line connecting the three, so it only works with plot-styles that draw marks but not lines.
Is there a pleasant way to tell matplotlib that I would like to use the same cycle state to draw multiple lines?