plotly - Plotly - yaxis 最小值和最大值未显示
问题描述
我正在使用 plotly 创建一些情节。我没有修改 y 轴范围,但我不喜欢图表显示 y 轴的方式。在附加的图像中,图表 y 轴数从 25 到 40,但我的数据略高于 40 和低于 25。是否可以选择强制 y 轴始终高于我拥有的最小值和最大值? 另外,是否可以让 y 轴从边缘开始?(以紫色突出显示)
感谢您的时间!
编辑:正如评论中所要求的,我在下面添加了我的代码:
fig= go.Figure()
fig.update_layout(
template="simple_white",
font=_a_font,
height=400,
legend=dict(
orientation="h",
yanchor="bottom",
y=1.02,
xanchor="left",
x=0,
font=dict(size=16),
itemclick=False,
itemdoubleclick=False,
),
)
fig.update_layout(xaxis=dict(range=x_range, mirror=True, tickmode='linear', tick0=0,dtick=1))
fig.update_yaxes(showgrid=True,mirror=True)
fig.add_trace(go.Scatter(x=sub_x_data,
y=y,
mode="lines+markers",
name=legend_name,
line=dict(color=get_driver_color(legend_name)),
textposition="bottom center",
text = h_data,
hoverinfo="text"))
解决方案
查看您的代码会很有帮助,因为此图表看起来不像 Plotly 中的默认样式图表。
话虽如此,您应该能够手动设置范围,并指定第一个刻度的位置:fig.update_yaxes(range=[20, 45], tick0=0)
推荐阅读
- machine-learning - 使用 Keras 加快模型评估速度
- rust - 如何不将进度条数据与其他输出混合?
- node.js - 服务器发送的事件没有从 React 和 NodeJs 的流中接收消息
- python - 找不到 Django 博客页面 (404) - 没有帖子与给定的查询匹配
- bixby - 当 Bixby 胶囊启动时调用特定操作
- dask - 将 NFS 与 Dask 工作人员一起使用
- reactjs - 如何使用打字稿为 HOC 编写通用类型?
- django - 在 Django 模板中聚合相关的整数字段值
- python - 读取txt文件中的关键字,并打印添加文本+关键字
- variables - 在商店页面显示最大可变价格