【问题标题】:"AttributeError: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width " with pandas_bokeh\"AttributeError: unexpected attribute \'plot_width\' to figure, similar attributes are outer_width, width or min_width \" with pandas_bokeh
【发布时间】:2023-01-03 06:39:52
【问题描述】:

我正在尝试使用pandas_bokeh创建一个带有熊猫数据框的折线图,我称之为bucketed_df

import pandas_bokeh
pandas_bokeh.output_notebook()

bucketed_df.plot_bokeh(kind='line')

出于某种原因我得到了错误

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

我不确定这是什么或如何修复它。我正在使用 python 3.9 和 jupyter notebooks

我在其上方的单元格中有一个 matplotlib 折线图。我认为这可能存在一些问题。

此外,如果有人知道任何更好的交互式图表,我愿意切换到不同的库。

【问题讨论】:

  • 你能分享一个 bucketed_df 的样本吗? (只要类型和示例相似,填充假数据就可以)
  • 它的索引是一个日期时间对象,并且有一个名为 id 的列,其中仅包含整数。

标签: pandas dataframe graphing pandas-bokeh


【解决方案1】:

我在最近安装的 bokeh==3.0.1 上遇到了类似的错误。

如果我使用 pip install --upgrade bokeh==2.4.3 安装版本 2.4.3(最新版本),错误就会消失

似乎 3.0.0 中有一个尚未解决的重大变化。如果您有时间,请将此问题发布到https://github.com/bokeh/bokeh/issues

【讨论】:

  • 对于那些在他们自己的代码中出现 bokeh 错误的人(我做到了 - 这个问题是搜索中的第一个结果):在 3.0.0 bokeh 版本中,图形的 plot_width 属性是替换为width。同样,plot_height 被替换为 height。即使在最后的2.x.x release docs中,它们也被描述为widthheight的“兼容性别名”。
【解决方案2】:

对不起,我不能评论...

我按照@beep_check 的建议降级到 2.4.3,但又收到另一个错误:AttributeError: unexpected attribute 'label' to Line, possible attributes are js_event_callbacks, js_property_callbacks, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, name, subscribed_events, syncable, tags, x or y

与原始错误不同,至少我正在使用该属性。我删除了label 属性,然后它抱怨linewidth。我将其替换为line_width

现在它没有策划任何事情。这似乎不是他们声称的直接替代品。

【讨论】:

    猜你喜欢
    • 2016-06-10
    • 1970-01-01
    • 2020-05-20
    • 2022-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多