首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

怎么在matplotlib中两个坐标轴之间画一条直线光标

2012-09-28 
如何在matplotlib中两个坐标轴之间画一条直线光标看看下面的例子和效果吧# -*- coding: utf-8 -*-from mat

如何在matplotlib中两个坐标轴之间画一条直线光标

看看下面的例子和效果吧

# -*- coding: utf-8 -*-from matplotlib.widgets import MultiCursorfrom pylab import figure, show, npt = np.arange(0.0, 2.0, 0.01)s1 = np.sin(2*np.pi*t)s2 = np.sin(4*np.pi*t)fig = figure()ax1 = fig.add_subplot(211)ax1.plot(t, s1)ax2 = fig.add_subplot(212, sharex=ax1)ax2.plot(t, s2)multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1)show()


下面是图形效果,看随着光标的移动,在两个图之间会画一条竖线

 

怎么在matplotlib中两个坐标轴之间画一条直线光标

这个功能有时还是比较有用的

热点排行