【发布时间】:2018-11-17 07:04:25
【问题描述】:
已尝试使用公共滑块在共享 x 轴上实现多个绘图。在滑块更新时,屏幕闪烁过多。这怎么可能避免。这是我使用的代码示例。
%matplotlib inline
from ipywidgets import interactive
import matplotlib.pyplot as plt
import numpy as np
''' 30% window size on the selected time on slider'''
data_size=round(M.Timestamp.size*0.30)
plt.close('all')
def f(m):
plt.figure(2)
x=M['Timestamp']
y1=M['Value']
'''define boundary limits for both axis'''
min_x=0 if m-data_size < 0 else m-data_size
max_x=M.Timestamp.size if m+data_size > M.Timestamp.size else m+data_size
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
ax1.plot(x[min_x:max_x],y1[min_x:max_x],color='r')
ax1.set_title('Sharing both axes')
ax2.plot(x[min_x:max_x],y1[min_x:max_x],color='b')
ax3.plot(x[min_x:max_x],y1[min_x:max_x],color='g')
plt.xticks(rotation=30)
interactive(f, m=(0, M.Timestamp.size))
当尝试更新滑块移动时的 xlimit 时,图表是空白的,因此使用数据子集来更新图表
【问题讨论】:
-
你能提供一些虚拟数据吗?你没有定义你的数据集
M。
标签: python-3.x matplotlib jupyter-notebook ipywidgets