python - 如何获得 Plotly 图的 x 轴范围?

标签 python ipython jupyter jupyter-notebook plotly

当您放大散点图时,我试图检索 x 轴的范围,但是当我尝试使用以下方法访问它时: 图[‘布局’][‘x轴’][‘范围’] 它只是返回“无”。

这是我用来创建图表的代码:

# self.plot contains the dataframe passed to the function to be plotted
self.plot = df
# Creates the plotly plot figure
self.fig = self.plot.iplot(asFigure=True,kind='scatter', xTitle='Date', yTitle='Temperature')
# Displays the plot
iplot(self.fig, show_link=False)

我正在使用袖扣从 pandas DataFrame 创建绘图,因此我没有明确将 layout.xaxis.range 设置为任何值。如果有帮助的话,我还使用 Jupyter Notebook 来显示图表。那么有没有什么办法可以得到plot当前 View 窗口的x轴范围呢?提前致谢!

最佳答案

目前使用 python 似乎不可能。在 community.plot.ly 上有一个帖子上面写着:

Graph parameters don’t dynamically change with chart actions. However, as you zoom, the plot does emit data regarding the new x-axis range, you’re unable to to access this information directly in Python. Instead you’d have to use javascript: https://plot.ly/javascript/zoom-events/

关于python - 如何获得 Plotly 图的 x 轴范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37885375/

相关文章:

python - jupyter notebook 在评估 cell 后跳转

python - 如何使用注释返回多个值?

python-2.7 - 增加 python 2.7 中的递归限制和堆栈大小

python - 检查 Pandas 数据框索引中是否存在值

python - 在 Ubuntu 中编译 Python 2.6.6 并需要外部包 wxPython、setuptools 等...

python - 通过单击 Bokeh 中的按钮运行 python 代码

python - Django 模型 radio 输入

python - 反混淆:简化 Python3 表达式

python - 如何在 Python 中生成 HTML 报告?

python - model.add(Dense, (133)) 的 Keras 语法错误