def generate_subplots(self, x, *args):
def _on_xlims_change(axes):
# reset the x-axis format when the plot is resized
axes.get_xaxis().set_major_formatter(DateFormatter('%H:%M:%S'))
i = 0
numplots = len(args)
fig = plt.figure()
self.cidclick = fig.canvas.mpl_connect('button_press_event', self.onclick)
self.cidrelease = fig.canvas.mpl_connect('button_release_event', self.onrelease)
self.cidmotion = fig.canvas.mpl_connect('motion_notify_event', self.onmotion)
for arg in args:
if i == 0:
a = fig.add_subplot(numplots, 1, i+1)
else:
a = fig.add_subplot(numplots, 1, i+1, sharex=self.axes[0])
a.plot(x.to_pydatetime(), arg)
a.fmt_xdata = DateFormatter('%H:%M:%S')
a.grid(True)
a.callbacks.connect('xlim_changed', _on_xlims_change)
self.axes.append(a)
i += 1
if not mpl.is_interactive():
fig.show()
self.figure = fig
plt.show()
# TO DO: Consider PatchCollection for rectangles.
评论列表
文章目录