Bajzel
Bajzel

Reputation: 63

Python, Pyplot - How to move two plots at the same time?

I have two separate plots made by pyplot using code like this:

img=imread(name)
        g=figure(1)
        imshow(img)
        g.show()

These plots are two different images of the same object.

I need a way to redraw the second plot when I move or change the scale of the first one.

I know how to calculate the position in the other coordinate system and how to set plot limits but I have no idea how to force the second image to refresh when I move around the first one.

Upvotes: 1

Views: 213

Answers (2)

Bajzel
Bajzel

Reputation: 63

I figure it out with:

def onclick(self):
    ...
    g.canvas.draw()
refresh=f.canvas.mpl_connect('button_release_event', onclick)

where:

img=imread(name)
f=figure(1)
imshow(img)
f.show()

img2=imread(name)
g=figure(2)
imshow(img2)
g.show()

Upvotes: 0

FTA
FTA

Reputation: 345

g.canvas.draw() should refresh the image drawn in g. See here for more info.

Upvotes: 1

Related Questions