coords_demo.py
来自「非原创。很好的python例子」· Python 代码 · 共 38 行
PY
38 行
#!/usr/bin/env python"""An example of how to interact with the plotting canvas by connectingto move and click events"""import sysfrom pylab import *t = arange(0.0, 1.0, 0.01)s = sin(2*pi*t)ax = subplot(111)ax.plot(t,s)def on_move(event): # get the x and y pixel coords x, y = event.x, event.y if event.inaxes: ax = event.inaxes # the axes instance print 'data coords', event.xdata, event.ydatadef on_click(event): # get the x and y coords, flip y from top to bottom x, y = event.x, event.y if event.button==1: if event.inaxes is not None: print 'data coords', event.xdata, event.ydatabinding_id = connect('motion_notify_event', on_move)connect('button_press_event', on_click)if "test_disconnect" in sys.argv: print "disconnecting console coordinate printout..." disconnect(binding_id)show()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?