python - 具有多个 y 值的 hvplot 不会绘图
问题描述
我想用 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)
解决方案
你的代码是正确的。
总之,它因此取决于您使用的库版本。
当您升级到散景 1.4.0、hvplot 0.5.2 和 holoviews 1.12.6 时,它可以工作。
推荐阅读
- javascript - JSX 未在 FileReader 中返回函数
- java - 有导航抽屉时无法点击卡片
- sonarqube - 我正在使用 Planing 在 CentOS-7 上的 UAT 环境中使用声纳 7.9,但在启动 sonar-7.9 时遇到了一些问题
- php - Cron 选项卡不运行大多数任务
- java - 如何使用 java 库在图像上绘制坐标?
- memory-management - Xamarin.Forms 导航(内存管理)
- java - 如何从 iframe 中清除缓存?
- model-view-controller - 为什么我们必须在模型和迁移时设置数据库的关系?阿多尼斯
- ios - 使用 UIRefreshControl 刷新 tableview
- javascript - 为什么点击时价值相同?