4

When I run this in one cell, both plot lines are blue. I could have sworn I saw Wes do a demo of baby names with two plots where the two plot lines came out in different colors without having to specify a color:

pd.Series(randn(100)).cumsum().plot()
pd.Series(randn(100)).cumsum().plot()

Yes, it was at 2:06:44 of this YouTube video: http://www.youtube.com/watch?v=w26x-z-BdWQ

4

2 回答 2

3

You just need to pass a couple of kwargs to the call to plot

import numpy as np
import pandas as pd
import matplotlib.pyplot

fig, ax = plt.subplots()
pd.DataFrame(np.random.randn(100, 2)).cumsum().plot(ax=ax)
于 2013-01-12T18:08:05.977 回答
1

I'm not sure how Wes did it in the video, but when using plot(df.index, df.column) and do that several times with different columns, then the graphs have different colors.

(I'm using the plot command from ipython --pylab) for this. )

于 2013-01-12T10:46:56.693 回答