gpt4 book ai didi

python - 具有多个 y 值的 hvplot 不会绘制

转载 作者:行者123 更新时间:2023-12-01 06:59:03 31 4
gpt4 key购买 nike

我想用 hvplot “面积绘制”一个简单的数据框(如下所示: https://hvplot.pyviz.org/user_guide/Plotting.html ),但代码不起作用。由于我是 hvplot 新手,我不太明白错误消息

将数据框绘制为“条形图”

df.hvplot.bar(x='col2', y=['col1', 'col3'])

有点管用。但传说并没有说到点子上。与面积图相同不起作用。

import pandas as pd
import panel as pn
import hvplot.pandas
import matplotlib.pyplot as plt

d = {'col1': [1, 2,3,4,5], 'col2': ['a','b', 'c', 'd', 'e'], 'col3': [11,12,13,14,15]}
df = pd.DataFrame(data=d)

df.hvplot.area(x='col2', y=['col1', 'col3'])

运行我的代码会出现以下错误消息:

AttributeError: unexpected attribute 'plot' to Legend, possible attributes are background_fill_alpha, background_fill_color, border_line_alpha, border_line_cap, border_line_color, border_line_dash, border_line_dash_offset, border_line_join, border_line_width, click_policy, glyph_height, glyph_width, inactive_fill_alpha, inactive_fill_color, items, js_event_callbacks, js_property_callbacks, label_height, label_standoff, label_text_align, label_text_alpha, label_text_baseline, label_text_color, label_text_font, label_text_font_size, label_text_font_style, label_text_line_height, label_width, level, location, margin, name, orientation, padding, spacing, subscribed_events, tags, title, title_standoff, title_text_align, title_text_alpha, title_text_baseline, title_text_color, title_text_font, title_text_font_size, title_text_font_style, title_text_line_height or visible

:NdOverlay [Variable]
:Area [col2] (value,Baseline)

最佳答案

您的代码是正确的。
总之,这取决于您使用的库版本。
当您升级到 bokeh 1.4.0、hvplot 0.5.2 和 Holoviews 1.12.6 时,它可以工作。

关于python - 具有多个 y 值的 hvplot 不会绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58712950/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com