⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 span_selector.py

📁 非原创。很好的python例子
💻 PY
字号:
#!/usr/bin/env python"""The SpanSelector is a mouse widget to select a vmin/vmaxrange.  When you left click drag in the axes, a rectangle shows theselected region.  When you release, the rectangle disappears and acallback is called with min/max."""import pylabfrom matplotlib.widgets import SpanSelectorfig = pylab.figure(figsize=(8,6))ax = fig.add_subplot(211, axisbg='#FFFFCC')x,y = 4*(pylab.rand(2,100)-.5)ax.plot(x,y,'o')ax.set_xlim(-2,2)ax.set_ylim(-2,2)ax.set_title('Press left mouse button and drag to test')def onselect(vmin, vmax):    print vmin, vmax# set useblit True on gtkagg for enhanced performancespan = SpanSelector(ax, onselect, 'horizontal', useblit=False,                    rectprops=dict(alpha=0.5, facecolor='red') )ax2 = fig.add_subplot(212)ax2.plot([1,2,3])span2 = SpanSelector(ax2, onselect, 'vertical')pylab.show()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -