Python 如何使用plotly中的rangebreaks?
我想使用plotly从某些绘图中的xaxis中删除某些间隔。我从中找到了附带的示例。但运行它会给我带来错误 ValueError:为类型为的对象指定的属性无效 plotly.graph_objs.layout.XAxis:“rangebreaks” 我甚至升级了我的阴谋版本。我如何使用rangebreaks属性Python 如何使用plotly中的rangebreaks?,python,plotly,Python,Plotly,我想使用plotly从某些绘图中的xaxis中删除某些间隔。我从中找到了附带的示例。但运行它会给我带来错误 ValueError:为类型为的对象指定的属性无效 plotly.graph_objs.layout.XAxis:“rangebreaks” 我甚至升级了我的阴谋版本。我如何使用rangebreaks属性 import plotly.express as px import pandas as pd df = pd.read_csv('https://raw.githubuserconte
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\u rangebreaks.py ..\Lib\site packages\plotly\validators\layout\xaxis\u rangebreaks.py