I would like to plot an image and along with traces along two of its axes. I want shared axes (x for one trace and y for the other), no space between the plots but also an equal aspect ratio for the image. I work in Python 3.6.
With GridSpec (I have also tried with subplots), I can accomplish the first part:
However, if I force an equal aspect ratio on the image, I get this
It seems I cannot figure out how to have a square image with no spaces around...
Here is the relevant part of my code (I also have a version using subplots):
h, w = plt.figaspect(1)
fig = plt.figure(figsize = (h, w))
grid = fig.add_gridspec(nrows = 2, ncols = 2,
hspace = 0, wspace = 0, width_ratios = [2, 1],
height_ratios = [1, 2])
ax = fig.add_subplot(grid[1,0])
ay = fig.add_subplot(grid[0,0], sharex = ax)
az = fig.add_subplot(grid[1,1], sharey = ax)
plt.setp(ay.get_xticklabels(), visible = False)
plt.setp(az.get_yticklabels(), visible = False)
# Add this for square image
ax.set_aspect('equal')
Any help?