这是我的代码:
我正在使用handlers
来移动和拉伸matplotlib主轴的插入轴。
RectangleSelector
这里它import numpy as np
import matplotlib.pyplot as plt
import matplotlib.widgets as widgets
def onselect(eclick, erelease):
if eclick.ydata<erelease.ydata:
erelease.ydata,eclick.ydata=eclick.ydata,erelease.ydata
if eclick.xdata<erelease.xdata:
erelease.xdata,eclick.xdata=eclick.xdata,erelease.xdata
axes2.set_ylim(eclick.ydata,erelease.ydata)
axes2.set_xlim(eclick.xdata,erelease.xdata)
axes2.set_position([eclick.xdata,eclick.ydata,erelease.xdata,erelease.ydata])
fig.canvas.draw()
fig = plt.figure()
axes1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
axes2 = fig.add_axes([0.2, 0.2, 0.4, 0.3])
axes2.autoscale(enable=True, axis='both', tight=None)
rp = dict(facecolor='white',edgecolor = 'black', alpha=0.5, fill=True)
rs=widgets.RectangleSelector(axes1, onselect, drawtype='box',interactive=True,
spancoords='pixels',rectprops = rp )
plt.show()
假设与RectangleSelector
一起,并且它应该是可拖动和可拉伸的。当我在axes2
中单独移动RectangleSelector
时,当时我axes1
RectangleSelector
的时候axes2
也在改变它的位置和大小。我现在想做什么。请事先帮助我。谢谢。