"AttributeError: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width " with pandas_bokeh
Asked Answered
S

5

7

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.

Sorci answered 1/11, 2022 at 19:33 Comment(2)
Are you able to share a sample of bucketed_df? (populated with fake data is fine as long as the types and examples are similar)Assessment
Its index is a datetime object and theres one column called id, which just contains integers.Sorci
U
10

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.

Underclothes answered 7/11, 2022 at 2:2 Comment(1)
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, they are described as "compatibility aliases" for width and height.Gelatinize
F
6

can be done like

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

or simply,

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

this may help.

Fremantle answered 17/2, 2023 at 10:43 Comment(1)
While this code may solve the question, including an explanation 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.Corelli
M
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']
Magisterial answered 17/1, 2023 at 17:7 Comment(1)
While that may work, I wonder if there is a solution that doesn't require removing features in the bokeh libraryCauterant
H
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.

Hasin answered 14/4, 2023 at 6:2 Comment(0)
R
0

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

Renz answered 24/5, 2023 at 10:53 Comment(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.Vyborg

© 2022 - 2024 — McMap. All rights reserved.