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

Barplot does not allow bar width to be set. #824

Closed
sjoerdvansteenkiste opened this issue Jan 19, 2016 · 6 comments
Closed

Barplot does not allow bar width to be set. #824

sjoerdvansteenkiste opened this issue Jan 19, 2016 · 6 comments

Comments

@sjoerdvansteenkiste
Copy link

The width argument can not be passed in barplot to specify the bar width. Since this is possible for boxplot I assume this was not intended.

@TomAugspurger
Copy link
Contributor

Do you have an example?

In [26]: s = pd.Series([1, 2, 3])

In [27]: s.plot.bar(width=.1)
Out[27]: <matplotlib.axes._subplots.AxesSubplot at 0x1127b07f0>

In [28]: plt.figure()
Out[28]: <matplotlib.figure.Figure at 0x11a777390>

In [29]: s.plot.bar(width=.9)
Out[29]: <matplotlib.axes._subplots.AxesSubplot at 0x11a781128>

narrow

wide

@sjoerdvansteenkiste
Copy link
Author

tips = sns.load_dataset("tips")
ax = sns.barplot(x="day", y="total_bill", hue="sex", data=tips, width=.3)

If I look inside then I can not find a way to alter the internal width parameter through barplot, and hence the initial width of .8 is used, scaled according to the number of bars. And as you correctly pointed out bar does allow for its width to be altered.

@mwaskom
Copy link
Owner

mwaskom commented Jan 19, 2016

It is intended.

@mwaskom mwaskom closed this as completed Jan 19, 2016
@brevans
Copy link

brevans commented May 26, 2016

This becomes a larger problem, especially on larger plots when hue is chosen. Please see:
http://stackoverflow.com/questions/36092363/seaborn-boxplots-changes-narrows-width-of-boxes-when-a-hue-is-chosen-how-migh

It forces you to choose between having tiny boxes (or violins, etc) or generating your own color palette and then having to create a legend from scratch.

@alexpetralia
Copy link

Was @brevans issue ever looked at? I'm having this same issue as well on barplots. If you put in the hue, you get thin bars.

@HannesHolste
Copy link

HannesHolste commented Feb 22, 2017

Agreed with @alexpetralia, this does seem to be unintended behavior when specifying hue and palette. Or if not unintended, then from a user's standpoint, the seaborn documentation around palette/hue is unclear or misleading.

I know of the solution suggested in: http://stackoverflow.com/questions/36092363/seaborn-boxplots-changes-narrows-width-of-boxes-when-a-hue-is-chosen-how-migh

I can submit a PR to clarify this behavior in the documentation if you'd like @mwaskom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants