0 votes
1 view
in Data Science by (43.2k points)

I want to plot multiple lines from a pandas dataframe and setting different options for each line. I would like to do something like:

testdataframe=pd.DataFrame(np.arange(12).reshape(4,3))

testdataframe.plot(style=['s-','o-','^-'],color=['b','r','y'],linewidth=[2,1,1])

This will raise some error messages:

  • linewidth is not callable with a list
  • In style, I can't use 's' and 'o' or any other alphabetical symbol, when defining colors in a list

Also, there is some more stuff which seems weird to me

  • When I add another plot command to the above code testdataframe[0].plot() it will plot this line in the same plot if I add the command testdataframe[[0,1]].plot() it will create a new plot.
  • If  would call testdataframe[0].plot(style=['s-','o-','^-'],color=['b','r','y']) it is fine with a list in style, but not with a list in color.

Hope somebody can help, thanks.

1 Answer

0 votes
by (92.8k points)

I think the answer lies in passing the color and style in the same parameter. The following sample of code works with pandas 0.19.2:

testdataframe=pd.DataFrame(np.arange(12).reshape(4,3))

testdataframe.plot(style=['r*-','bo-','y^-'], linewidth=2.0)

But, it seems that passing multiple line widths as an input to matplotlib is not possible.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...