Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single column DF plot, color problem #3486

Closed
httassadar opened this issue Apr 29, 2013 · 3 comments
Closed

single column DF plot, color problem #3486

httassadar opened this issue Apr 29, 2013 · 3 comments

Comments

@httassadar
Copy link

import pylab
import pandas.util.testing as put
df = put.makeTimeDataFrame()
pylab.figure()
df[ ['A'] ].plot(color = ['r'])
pylab.savefig('C:/tmp.png')

will give an error

raise ValueError('to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
ValueError: to_rgba: Invalid rgba arg "['r']"

All you need to do is to de-list the color parameter

df[ ['A'] ].plot(color = 'r')    

No problem if df is more than one columns.

df.plot(color = ['r','k'])
@ghost
Copy link

ghost commented May 10, 2013

Thanks. This is actually passed over to matplotlib as-is via **kwds, the user is responsible for
passing in something matplotlib likes.

closing as 'won't fix'.

@ghost ghost closed this as completed May 10, 2013
@httassadar
Copy link
Author

Thanks. Maybe I'm not making myself clear enough

Say you start with a big DF and a list of its columns and assign a color to each column.

A = DF.columns
C = ['r','b','g',...]

Now you do some manipulations to filter out unwanted columns, eg

A = A[:x]
C = C[:x]

and in the end, you plot

DF[A].plot(color=C)

Now if x > 1, you won't have any problem, but it's possible x=1 and will result in the above error.

I don't think it's the user's responsibility here to write an awkward check

color = C[0] if len(C)==1 else C

@ghost
Copy link

ghost commented May 10, 2013

Thanks, I do see your point. The implicit rule of thumb is: if it's not an explicit argument
of the method, pandas is not responsible. You scenario probably applied to other arguments besides
colors. I think it is better to tell the user he is responsible then to selectively special-case some
arguments and not others.

It may be possible to make singleton dataframes work as expected here without touching
kwds, PRs welcome.

@ghost ghost reopened this May 10, 2013
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue May 4, 2017
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue May 11, 2017
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.20.2, Someday May 14, 2017
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue May 29, 2017
TomAugspurger added a commit that referenced this issue May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants