'Python - matplotlib: how to change RectangleSelector properties

Is it possible to change RectangleSelector properties after it has been created?

Let's say I created a figure with the following rectangle:

from matplotlib.widgets import RectangleSelector
import matplotlib.pyplot as plt

def on_click(eclick, erelease):
    pass

fig, current_ax = plt.subplots()
RS = RectangleSelector(current_ax, on_click, drawtype='box', 
                        useblit=True, button=[1, 3], interactive=True,
                        minspanx=1, minspany=1, spancoords='pixels',
                        rectprops=dict(linestyle='-', color='g', 
                                       fill=True, alpha=1))
plt.show()

What if I want to change the rectangle color?

I would do:

RS.rectprops['color'] = 'r'
RS.canvas.draw()
fig.canvas.draw()

But this doesn't affect the color of the rectangle.

Any clue?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source