"attributeerror: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width " with pandas_bokeh in python

The error message "AttributeError: Unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width, or min_width" indicates that you are trying to set the attribute 'plot_width' on a plot figure using pandas_bokeh library in Python.

To resolve this error, you need to use the correct attribute name to set the width of the plot. In the case of pandas_bokeh library, you should use the attribute 'width' instead of 'plot_width'.

Here's an example of how you can set the width of a plot using pandas_bokeh:

main.py
import pandas as pd
import pandas_bokeh

# Create a sample DataFrame
df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})

# Enable pandas_bokeh
pandas_bokeh.output_notebook()

# Create a plot
plot = df.plot_bokeh(kind='line', x='x', y='y', width=500)  # Use 'width' attribute instead of 'plot_width'

# Show the plot
pandas_bokeh.show(plot)
341 chars
15 lines

In the above example, we first import the necessary libraries, create a sample DataFrame, and enable pandas_bokeh to output the plot in the Jupyter Notebook. Then, we use the 'plot_bokeh' function on the DataFrame to create a line plot, and we set the width of the plot to 500 using the 'width' attribute.

Make sure to replace the sample DataFrame and the plot type with your own data and desired plot type.

I hope this helps! Let me know if you have any further questions.

related categories

gistlibby LogSnag