有没有办法开始使用 plotly 在特定区域上缩放的绘图? [英] Is there a way to start a plot already zoomed on a specific area using plotly?

查看:81
本文介绍了有没有办法开始使用 plotly 在特定区域上缩放的绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 plotly 制作的散点图(特别是在 Jupyter Notebook 上使用 Python API 离线绘图),如您所知,plotly 使用户可以轻松缩放和框定特定区域,但我想要该图开始专注于我选择的特定领域.

I have a scatter plot made with plotly (specifically offline plotly with the Python API on a Jupyter Notebook) and as you know, plotly makes it easy for the user to zoom and frame specific areas, but I'd like the plot to start already focussed on a specific area of my choosing.

我在文档中找不到任何相关内容(可能是因为我不知道在哪里查找或查找哪些术语).有没有办法做到这一点,如果有,怎么做?使用子图而不是 Figure 对象时,设置有何不同?

I can't find anything relevant in the documentation (maybe because I don't know where to look or what terms to look up). Is there a way to do this, and if so, how? And how does the setting differ when using subplots rather than a Figure object?

推荐答案

当你指定你的 Layout 时,在 xaxisyaxis 参数下,你可以指定一个range,例如

When you specify your Layout, under the xaxis and yaxis parameters, you can specify a range, e.g.

import plotly.graph_objs as go

# ...    

layout = go.Layout(
    yaxis=dict(
        range=[0, 100]
    ),
    xaxis=dict(
        range=[100, 200]
    )
)
fig = go.Figure(data=data, layout=layout)

相关文档可以在 xaxis 中找到 这里yaxis 这里.

Documentation for this can be found for the xaxis here and yaxis here.

这篇关于有没有办法开始使用 plotly 在特定区域上缩放的绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆