如何从图例中使用距离转换?

问题描述 投票:1回答:1

我想在某些绘图中使用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()
python plotly
1个回答
0
投票

如果您正在运行最新版本的pally,则应该可以,也许可以尝试重新启动内核

和检查系统中是否有这些文件:... \ Lib \ site-packages \ plotly \ validators \ layout \ yaxis_rangebreaks.py.. \ Lib \ site-packages \ plotly \ validators \ layout \ xaxis_rangebreaks.py

© www.soinside.com 2019 - 2024. All rights reserved.