Is it possible to force the date ticks to be the same in two different
plots? For example, the attached figures cover the same time spans but
in one, the data are weekly and the other, monthly. While there is
nothing really wrong with different tick marks, aesthetically it would
be nice if they were both the same.
Yes, just use the “sharex” keyword to share the x-axis between the two. Not only will they have the same ticks and labels, but when you pan and zoom in one the other moves with it. The example below does not use dates, but it will work with dates just the same.
import matplotlib.pyplot as plt
import numpy as np
fig1 = plt.figure(1)
ax1 = fig1.add_subplot(111)
ax1.plot(np.random.randn(10,2)*10)
fig2 = plt.figure(2)
ax2 = fig2.add_subplot(111, sharex=ax1)
ax2.plot(np.random.randn(10,2)*10)
plt.show()
JDH
···
On Wed, Feb 8, 2012 at 1:12 PM, Ted To <rainexpected@…3956…> wrote:
Is it possible to force the date ticks to be the same in two different
plots? For example, the attached figures cover the same time spans but
in one, the data are weekly and the other, monthly. While there is
nothing really wrong with different tick marks, aesthetically it would
On Wed, Feb 8, 2012 at 1:12 PM, Ted To <rainexpected@...3956... > <mailto:rainexpected@…3956…>> wrote:
Is it possible to force the date ticks to be the same in two different
plots? For example, the attached figures cover the same time spans but
in one, the data are weekly and the other, monthly. While there is
nothing really wrong with different tick marks, aesthetically it would
be nice if they were both the same.
Yes, just use the "sharex" keyword to share the x-axis between the two.
Not only will they have the same ticks and labels, but when you pan and
zoom in one the other moves with it. The example below does not use
dates, but it will work with dates just the same.
import matplotlib.pyplot as plt
import numpy as np