Skip to content

BUG: barplot with log=True not working for values smaller than 1 #9905

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
jorisvandenbossche opened this issue Apr 15, 2015 · 2 comments · Fixed by #9914
Closed

BUG: barplot with log=True not working for values smaller than 1 #9905

jorisvandenbossche opened this issue Apr 15, 2015 · 2 comments · Fixed by #9914
Labels
Bug Regression Functionality that used to work in a prior pandas version Visualization plotting
Milestone

Comments

@jorisvandenbossche
Copy link
Member

s = pd.Series([0.1, 0.01, 0.001], index=['a', 'b', 'c'])
s.plot(kind='bar', log=True)

gives:

TypeError                                 Traceback (most recent call last)
<ipython-input-13-75b989d29042> in <module>()
      1 s = pd.Series([0.1, 0.01, 0.001], index=['a', 'b', 'c'])
----> 2 s.plot(kind='bar', log=True)

C:\Anaconda\lib\site-packages\pandas\tools\plotting.pyc in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   2517                  yerr=yerr, xerr=xerr,
   2518                  label=label, secondary_y=secondary_y,
-> 2519                  **kwds)
   2520 
   2521 

C:\Anaconda\lib\site-packages\pandas\tools\plotting.pyc in _plot(data, x, y, subplots, ax, kind, **kwds)
   2323         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   2324 
-> 2325     plot_obj.generate()
   2326     plot_obj.draw()
   2327     return plot_obj.result

C:\Anaconda\lib\site-packages\pandas\tools\plotting.pyc in generate(self)
    921         self._compute_plot_data()
    922         self._setup_subplots()
--> 923         self._make_plot()
    924         self._add_table()
    925         self._make_legend()

C:\Anaconda\lib\site-packages\pandas\tools\plotting.pyc in _make_plot(self)
   1884                 w = self.bar_width / K
   1885                 rect = bar_f(ax, self.ax_pos + (i + 0.5) * w, y, w,
-> 1886                              start=start, label=label, **kwds)
   1887             self._add_legend_handle(rect, label, index=i)
   1888 

C:\Anaconda\lib\site-packages\pandas\tools\plotting.pyc in f(ax, x, y, w, start, **kwds)
   1823         if self.kind == 'bar':
   1824             def f(ax, x, y, w, start=None, **kwds):
-> 1825                 start = start + self.bottom
   1826                 return ax.bar(x, y, w, bottom=start,log=self.log, **kwds)
   1827         elif self.kind == 'barh':

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

This was working in 0.14.1

@jorisvandenbossche jorisvandenbossche added Bug Visualization plotting Regression Functionality that used to work in a prior pandas version labels Apr 15, 2015
@jorisvandenbossche jorisvandenbossche added this to the 0.16.1 milestone Apr 15, 2015
@jorisvandenbossche
Copy link
Member Author

@sinhrks if you can have a look. If I revert the lines touching the handling of bottom in this commit 53cc1b7 (around lines 1700-1800 in plotting.py) it works for me (but not sure if that would be the best fix)

@sinhrks
Copy link
Member

sinhrks commented Apr 16, 2015

The line is required to handle bottom, but it didn't cared for start can be None (#3254):

https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py#L1869

Above condition is no longer required as current BarPlot always passes bottom kw. I'll prepare a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Regression Functionality that used to work in a prior pandas version Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants