我想使用plotly从某些图中的x轴中删除某些间隔。我找到了随附的示例https://plotly.com/python/time-series/ https://plotly.com/python/time-series/。但运行它给了我错误
ValueError:为类型的对象指定的属性无效
plotly.graph_objs.layout.XAxis: 'rangebreaks'
我什至升级了我的情节版本。如何使用 rangebreaks 属性?
import plotly.express as px
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig = px.scatter(df, x='Date', y='AAPL.High', range_x=['2015-12-01', '2016-01-15'],
title="Hide Gaps with rangebreaks")
fig.update_xaxes(
rangebreaks=[
dict(bounds=["sat", "mon"]), #hide weekends
dict(values=["2015-12-25", "2016-01-01"]) # hide Christmas and New Year's
]
)
fig.show()
如果你正在运行最新版本的plotly,这应该可以工作,也许尝试重新启动内核
和
检查您的系统中是否有这些文件:
...\Lib\site-packages\plotly\validators\layout\yaxis_rangebreaks.py
..\Lib\site-packages\plotly\validators\layout\xaxis_rangebreaks.py
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)