single column DF plot, color problem #3486

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

Comments

Projects
None yet
3 participants
@httassadar
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'])
@y-p

This comment has been minimized.

Show comment
Hide comment
@y-p

y-p May 10, 2013

Contributor

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'.

Contributor

y-p 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'.

@y-p y-p closed this May 10, 2013

@httassadar

This comment has been minimized.

Show comment
Hide comment
@httassadar

httassadar May 10, 2013

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

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
@y-p

This comment has been minimized.

Show comment
Hide comment
@y-p

y-p May 10, 2013

Contributor

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.

Contributor

y-p 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.

@y-p y-p 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

TomAugspurger added a commit that referenced this issue May 11, 2017

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.20.2, Someday May 14, 2017

pcluo added a commit to pcluo/pandas that referenced this issue May 22, 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

stangirala added a commit to stangirala/pandas that referenced this issue Jun 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment