【问题标题】:How do you get the range of the x-axis of a Plotly graph?如何获得 Plotly 图的 x 轴范围?
【发布时间】:2016-10-19 12:23:40
【问题描述】:

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

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

# 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 来显示图表,如果这有帮助的话。那么有什么方法可以获取绘图当前视图窗口的 x 轴范围吗?提前致谢!

【问题讨论】:

    标签: python ipython jupyter jupyter-notebook plotly


    【解决方案1】:

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

    图表参数不会随着图表操作而动态变化。然而, 当您缩放时,该图确实会发出有关新 x 轴范围的数据, 您无法直接在 Python 中访问此信息。 相反,您必须使用 javascript: https://plot.ly/javascript/zoom-events/

    【讨论】:

      猜你喜欢
      • 2017-12-26
      • 1970-01-01
      • 1970-01-01
      • 2019-09-06
      • 2017-06-09
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      • 2018-11-02
      相关资源
      最近更新 更多