Consider the following toy example:
import numpy as np
d = np.random.rand(160,100)
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis('off')
ax.set_xticklabels([]);
ax.set_yticklabels([]);
ax.imshow(d)
fig.add_axes([0, 0, 0.1, 0.5])
plt.show()
If I remove fig.add_axes
then it looks like this:
I don't understand the coordinate system used in fig.add_axes
. I expected (0,0) to be in the bottom left corner of the second picture, and the coordinates to run from 0 to 1 over the width and height of the second picture. What am I missing?
Please explain how the coordinate system works in this example, and also how I can position the axes relative to the image. The ultimate goal is to position a color bar on top of the image, below it, or to the right.