简体   繁体   English

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

[英]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.

相关问题 如何在带有子图的 plotly 图中设置辅助 x 轴及其范围? - How to set secondary x-axis and its range in plotly graph with subfigures? 如何使用 plotly express 在 x 轴上用时间绘制一些事件? - How to graph some events with time on x-axis with plotly express? 如何在 plotly 中获取德语字母格式的 x 轴 - how to get the x-axis in german letter format in plotly 有没有办法用 plotly 或 python 创建条形图可视化,其中 y 轴是 24 小时范围,x 轴是所有工作日? - Is there a way to create a bar graph visualization with plotly or python where the y-axis is 24hour range and x-axis is all the weekdays? 如何使用 x 轴上的时间值更改条形图中的 x 轴刻度/刻度? - How do you change the x-axis scale/ticks in a bar chart with time values in the x-axis? 如何使用 matplotlib 中的日期时间更改 x 轴的范围? - How do I change the range of the x-axis with datetimes in matplotlib? 绘制折线图以遵循 X 轴上的有序时间序列 - Plotly line graph to follow ordered time series on X-axis 绘图图未正确显示 x 轴值 - Plotly graph does not show x-axis values correctly 如何在 X 轴上获得具有相等间隔的日期范围的直方图? - How to get an histogram with range of dates with equal interval in X-axis? 如何为 Plotly 条形图设置 static x 轴值和图例集? - How to set a static set of x-axis values and legend for a Plotly Bar Graph?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM