我正在尝试使stacked bar plot example适应某些现有数据。在
我的数据帧的结构与示例中提供的类似。它可以作为CSV找到here。在
这是我的代码:
from bokeh.charts import Bar, output_file, show
from bokeh.charts.attributes import cat, color
from bokeh.charts.operations import blend
bar = Bar(
df,
values=blend('farfetch','harrods', 'lyst', 'mrporter','nastygal','neimanmarcus','netaporter','theoutnet','yoox', name='retailers', labels_name='retailers'),
label=cat(columns='index', sort=False),
stack=cat(columns='retailers', sort=False),
tooltips=[('retailers', '@retailers'), ('brands', '@index')]
)
show(bar)
执行此代码后,我得到以下堆栈跟踪:
^{pr2}$为什么会这样?在
据我所知,这是一个当
name
和labels_name
参数相同时发生的错误。在在您的例子中,它们都是
retailers
,因此您需要将标签更改为其他内容,例如rtlrs
。您还需要相应地更改堆栈和工具提示中的引用。在相关问题 更多 >
编程相关推荐