I have a problem which is similar to the one posted here. The difference is that I get unwanted white spaces inside the plot area when I plot two subplots which share axes via the sharex
and sharey
attributes. The white spaces persist even after setting autoscale(False)
. For example, using similar code as in the answer to the post mentioned above:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(2, 1, 1)
ax.imshow(np.random.random((10,10)))
ax.autoscale(False)
ax2 = fig.add_subplot(2, 1, 2, sharex=ax, sharey=ax) # adding sharex and sharey
ax2.imshow(np.random.random((10,10)))
ax2.autoscale(False)
plt.show()
results in this image.
I have also tried ax.set_xlim(0, 10)
and ax.set_xbound(0, 10)
as per suggestions here, but to no avail. How can I get rid of the extra white spaces? Any ideas would be appreciated.