I have multiple ax plot with partial code of RectangleSelector as below.
from matplotlib.widgets import RectangleSelector
import numpy as np
import matplotlib.pyplot as plt
from functools import partial
def select_callback(eclick, erelease, dataSize):
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata
//** I would like to set fix size of selection here **//
// ext = (0,dataSize,eclick.ydata,erelease.ydata)
// May be I need selected.draw_shape(ext)
fig = plt.figure(constrained_layout=True)
axs = fig.subplots(4)
x = np.linspace(0, 10, 1000)
selectors = []
for idx,ax in enumerate(axs):
ax.plot(x, np.sin(2*np.pi*x)) # plot something
selectors.append(RectangleSelector(
ax, partial(select_callback, dataSize=10),
useblit=True,
button=[1, 3],
minspanx=5, minspany=5,
spancoords='pixels',
interactive=True))
plt.show()
I would like to set fix size of selection with coordinate set e.g. x1, x2, y1, y2 after erelease callback done. Any advice or guidance on this would be greatly appreciated, Thanks.