当您放大散点图时,我试图检索 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/