我想使用plotly从某些图中的x轴中删除某些间隔。我从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()
Run Code Online (Sandbox Code Playgroud)