I am plotting a series of heatmaps using matplotlib. Without a shared y-axis, it works OK. I'm running into an issue when I try and share the y-axis though. The x-axis limits seem to get mangled.
Consider the following MWE:
import matplotlib
print matplotlib.__version__ # prints "1.4.2"
import matplotlib.pyplot as plt
data = [[1,2,3],
[4,5,6],
[7,8,9],
[10,11,12]]
nrows, ncols = 1, 4
fig, axes = plt.subplots(nrows, ncols, sharey=True)
for j in range(ncols):
xs = axes[j]
# seems to have no impact when sharey=True
#xs.set_xlim(-0.5, 2.5)
xs.imshow(data, interpolation='none')
plt.show()
The incorrect output of this looks like:
Whereas simply changing sharey=True
to sharey=False
results in the correct output (with the exception that I want the y-axis to be shared of course, which it now isn't):
Is there a way to fix this?