To this question I am referring to this example: https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html
I want to replace the sine plot to with a simple rectangle plot without coordinate system shown.
To be exactly, I want to change this part of the original code:
class MyStaticMplCanvas(MyMplCanvas):
"""Simple canvas with a sine plot."""
def compute_initial_figure(self):
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
self.axes.plot(t, s)
I found the rectangle class in Matplotlib: https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.Rectangle.html#examples-using-matplotlib-patches-rectangle
This should be a simple task. But I tried a lot on my own without sucess. One of my many tries looks like: (But it does not work)
class MyStaticMplCanvas(MyMplCanvas):
"""Simple canvas with a rectangle plot."""
def compute_initial_figure(self):
x = 10
y = 20
width = 10
height = 20
fig,ax = plt.subplots(1)
rect = mpatches.Rectangle((x, y), width, height)
ax.add_patch(rect)
self.axes.plot(rect)
Could anyone please help me out? Any help will be highly appreciated!