Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link axis between different plot (no subplots) using matplotlib

Here is my question. I know there is a simple way to link the axis of different plot if they are subplots in the same figure this way :

import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212, sharex=ax1)

But I wonder if there is a way to do the same link (when zooming on figure 1, I get the same zoom on figure 2 on one particular axis) when defining 2 different Figures (I want those graph to appear far from each other so I guess that I can't put them in the same Figure...)

Thanks a lot !

like image 876
Jdawleer Avatar asked Jan 23 '13 14:01

Jdawleer


1 Answers

You simply do the same thing, but with a different figure.

import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, sharex=ax1)
like image 111
tacaswell Avatar answered Sep 23 '22 11:09

tacaswell