5

I am trying to use pandas_bokeh to create a line graph with a pandas dataframe I call bucketed_df

import pandas_bokeh
pandas_bokeh.output_notebook()

bucketed_df.plot_bokeh(kind='line')

for some reason I get the error

AttributeError: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width

Im not sure what this is or how toi fix it. I am using python 3.9 and jupyter notebooks

I have a matplotlib linegraph in a cell above it. I am thinking there could be some issue with that.

Also if anyone knows any interactive graphs that are better I am open to switching to a different library.

5 Answers5

7

I'm getting a similar error on a recent install of bokeh==3.0.1.

The error goes away if I install version 2.4.3 (last release) with pip install --upgrade bokeh==2.4.3

It seems there was a breaking change in 3.0.0 that hasn't been addressed yet. If you have time, post this issue at https://github.com/bokeh/bokeh/issues.

beep_check
  • 159
  • 3
  • 11
  • 6
    For those who come here with the `bokeh` error in their own code (I did - and this question was the first result in the search): In the `3.0.0` `bokeh` release, the `plot_width` attribute of a figure was replaced with `width`. Similarly, `plot_height` was replaced with `height`. Even in the last [2.x.x release docs](https://docs.bokeh.org/en/2.4.3/docs/reference/plotting/figure.html?highlight=plot_width), they are described as "compatibility aliases" for `width` and `height`. – natka_m Dec 09 '22 at 13:54
3

can be done like

p=figure(min_width=500, height=500)

or simply,

p=figure(width=500, height=500)

this may help.

Moritz Ringler
  • 9,772
  • 9
  • 21
  • 34
user3248647
  • 57
  • 1
  • 6
  • 1
    While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Yunnosch Feb 17 '23 at 11:07
1

temp way:

File ".../lib/python3.10/site-packages/pandas_bokeh/plot.py", line 439, in plot

Add

figure_options['width'] = figure_options['plot_width']
figure_options['height'] = figure_options['plot_height']
del figure_options['plot_width']
del figure_options['plot_height']
Bobby
  • 11
  • 1
  • 1
    While that may work, I wonder if there is a solution that doesn't require removing features in the bokeh library – Matthew Cox Jan 23 '23 at 15:01
0

The error has been reported in the GitHub of pandas_bokeh : https://github.com/PatrikHlobil/Pandas-Bokeh/issues/128 But unfortunately, no solution has been found yet, except for someone using the latest commit of the github... For what it's worth.

francoua
  • 13
  • 4
0

this temp way works but you must change file ".../lib/python3.10/site-packages/pandas_bokeh/geoplot.py" not plot.py

ZHar
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 24 '23 at 13:03