[英]How do you get the range of the x-axis of a Plotly graph?
I'm trying to retrieve the range of the x-axis when you zoom in a plotly scatter plot, but when I tried to access it using: figure['layout']['xaxis']['range'] it just returns 'None'.我想,当你在一个plotly散点图缩小检索x轴的范围内,但是当我试图访问它使用:数字[“布局”] [“x轴”] [“范围”]它只返回“无”。
This is the code that I am using to create the graph:这是我用来创建图形的代码:
# 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)
I'm using cufflinks to create the plot from a pandas DataFrame so I don't explicitly set the layout.xaxis.range to anything.我正在使用袖扣从 Pandas DataFrame 创建绘图,所以我没有明确地将 layout.xaxis.range 设置为任何内容。 Also I'm using a Jupyter Notebook to display the graph, if that helps at all.
另外我使用的是笔记本Jupyter显示图形,有没有什么帮助的。 So is there any way of getting the range of the x-axis of the current view window of the plot?
那么,有没有让情节的当前视图窗口的x轴的范围内的任何方式? Thanks in advance!
提前致谢!
That does not seem to be possible at the moment using python.目前使用 python 似乎不可能。 There's a post on community.plot.ly that says:
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.
但是,当您缩放时,绘图会发出有关新 x 轴范围的数据,您无法直接在 Python 中访问此信息。 Instead you'd have to use javascript: https://plot.ly/javascript/zoom-events/
相反,您必须使用 javascript: https : //plot.ly/javascript/zoom-events/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.