Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Series markers in pandas dataframe plots

I'm plotting a pandas dataframe which contains multiple time series. I have more series than the number of colors matplotlib chooses from, so there is ambiguity in mapping legend colors to plots.
I haven't seen any matplotlib examples that assigns markers as a batch across all series and I'm wondering if there's a way to pass a list of marker styles that df.plot() can rotate through in the same way it chooses colors.

df.plot(markers = ??)

like image 596
Robert Sim Avatar asked Oct 29 '25 10:10

Robert Sim


1 Answers

A for loop would be sufficient:

df = pd.DataFrame(np.arange(16).reshape(4,-1))

for c,m in zip(df,'oxds'):
    df[c].plot(marker=m)

plt.legend()

Output:

enter image description here

like image 86
Quang Hoang Avatar answered Oct 31 '25 00:10

Quang Hoang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!