Skip to content

Bar Plot does not allow to change linewidth #1658

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

Closed
CRP opened this issue Jul 23, 2012 · 6 comments
Closed

Bar Plot does not allow to change linewidth #1658

CRP opened this issue Jul 23, 2012 · 6 comments
Milestone

Comments

@CRP
Copy link
Contributor

CRP commented Jul 23, 2012

linewidth for barplots (ie the edge lines of the bars) appears to be fixed at 1. Would it be possible to allow it to be set freely?

@changhiskhan
Copy link
Contributor

What version of pandas are you on?
I just tried it on master and passing in linewidth>1 looks fine. Would you be able to give the latest a shot?

@CRP
Copy link
Contributor Author

CRP commented Jul 24, 2012

I am on 0.8.1, just upgraded.

Here is my output:

a.plot(kind='bar',stacked=True)
Out[121]: <matplotlib.axes.AxesSubplot at 0x1713d9cd0>

so this works fine. If I specify a linewidth keyword it breaks, as the method bar_f already has a keyword linewidth:

a.plot(kind='bar',stacked=True,linewidth=2)

TypeError Traceback (most recent call last)
in ()
----> 1 a.plot(kind='bar',stacked=True,linewidth=2)

/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, *_kwds)
1215 sort_columns=sort_columns, secondary_y=secondary_y,
1216 *_kwds)
-> 1217 plot_obj.generate()
1218 plot_obj.draw()
1219 if subplots:

/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in generate(self)
573 self._compute_plot_data()
574 self._setup_subplots()
--> 575 self._make_plot()
576 self._post_plot_logic()
577 self._adorn_subplots()

/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _make_plot(self)
1075
1076 rect = bar_f(ax, self.ax_pos, y, 0.5, start=start,
-> 1077 label=label, linewidth=1, **kwds)
1078 pos_prior = pos_prior + np.where(mask, y, 0)
1079 neg_prior = neg_prior + np.where(mask, 0, y)

TypeError: f() got multiple values for keyword argument 'linewidth'

@changhiskhan
Copy link
Contributor

Oh I see. For some reason the linewidth keyword defaulted to 1 for the bar plot if stacked was True (I was quickly checking it without stacked). I'll put in a fix.

On Jul 24, 2012, at 3:16 AM, Christian Prinoth wrote:

I am on 0.8.1, just upgraded.

Here is my output:

a.plot(kind='bar',stacked=True)
Out[121]: <matplotlib.axes.AxesSubplot at 0x1713d9cd0>

so this works fine. If I specify a linewidth keyword it breaks, as the method bar_f already has a keyword linewidth:

a.plot(kind='bar',stacked=True,linewidth=2)

TypeError Traceback (most recent call last)
in ()
----> 1 a.plot(kind='bar',stacked=True,linewidth=2)

/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, *_kwds)
1215 sort_columns=sort_columns, secondary_y=secondary_y,
1216 *_kwds)
-> 1217 plot_obj.generate()
1218 plot_obj.draw()
1219 if subplots:

/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in generate(self)
573 self._compute_plot_data()
574 self._setup_subplots()
--> 575 self._make_plot()
576 self._post_plot_logic()
577 self._adorn_subplots()

/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _make_plot(self)
1075
1076 rect = bar_f(ax, self.ax_pos, y, 0.5, start=start,
-> 1077 label=label, linewidth=1, **kwds)
1078 pos_prior = pos_prior + np.where(mask, y, 0)
1079 neg_prior = neg_prior + np.where(mask, 0, y)

TypeError: f() got multiple values for keyword argument 'linewidth'


Reply to this email directly or view it on GitHub:
#1658 (comment)

@CRP
Copy link
Contributor Author

CRP commented Jul 24, 2012

Thanks, btw, I also noticed an inconsistent handling of x axis formatting: eg the size of xaxis ticklabels is controlled by the fontsize parameter, but this does not affect y axis and/or legend. Further, even if the fontsize keyword is not explicitly specified, there is a default somewhere that overrides matplotlib rc settings. maybe it would be better not to handle fontsize at pandas level and fall back on matplotlib defaults.

@ghost ghost assigned changhiskhan Jul 24, 2012
@changhiskhan
Copy link
Contributor

Yeah, I think it absolutely makes sense to push as much of the styling down to matplotlib as possible.
We are working on a more unified plotting API that will be part of v0.9, please stay tuned.
Thanks for the feedback

@Aerickk
Copy link

Aerickk commented Jun 23, 2019

bar
I would like to have this graphic with python. can someone help me

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

3 participants