Matplotlib/Pandas:使用时间序列缩放绘图的一部分
问题描述
我的任务很简单:我有一个时间序列 ts
(2010 年和 2014 年之间的欧元瑞士法郎每日汇率)来绘制.在该图中,我想通过放大某个时间间隔来突出显示它.但是,缩放后的窗口仍然是空的(参见下面的代码).此外,我在选择放大窗口的 x 范围时遇到了问题,因为我不知道如何正确地将日期转换为 matplotlib 的内部整数表示.
my task is simple: I have a time series ts
(Euro Swiss Franc daily exchange rates between 2010 and 2014) to plot. In that plot I would like to highlight a certain time interval by zooming into it. However, the zoomed window stays simply empty (see code below). Furthermore, I have a problem by selecting the x-range of the zoomed-in window since I do not know how to properly transform the dates to the internal integer representation of the matplotlib.
提前感谢您的帮助!
这是我的代码:
推荐答案
我没用过pandas
,但是我觉得问题出在你为axins.set_xlim(x1, x2)
,它们似乎超出了范围.我只是使用了 matplotlib
的绘图功能并更改了范围,并获得了缩放后的图像.
I have never used pandas
, but I think that the problem is the range you are choosing for axins.set_xlim(x1, x2)
, they seem to be outside of the range. I just used the plotting capabilities of matplotlib
and changed the range, and I obtained an image with the zoom.
这篇关于Matplotlib/Pandas:使用时间序列缩放绘图的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!