I'm tying to overlay a scatter plot and a matrix plot, in such a way that the the relative sizes of the markersize
and the boxes given in ax.matshow()
do not change with scale.
For example, consider the following code:
import matplotlib.pyplot as plt
import numpy as np
ax = plt.axes()
mat = np.random.random((5,5))
ax.matshow(mat, aspect='equal')
ax.scatter([1], [2], marker='v', s=700)
This returns the following image:
However, let's say now I want to change the dimension of the matrix plot to (5,20). Then the code
ax = plt.axes()
mat = np.random.random((5,20))
ax.matshow(mat, aspect='equal')
ax.scatter([1], [2], marker='v', s=700)
returns the image
Note how the triangle I want to plot is now larger than the box shown in ax.matshow()
. I would like them to scale together in a way that the triangle always fits within the matrix plot box. Any ideas on how to do this?