If I plot two images with cmap="gray":
So how do I obtain the same light grey on Im2 ?
import matplotlib.pyplot as plt
import numpy as np
Im1 = np.array([[0.1,0.2],[0.02,0.002]])
plt.subplot(1, 2, 1)
plt.imshow(Im1, cmap="gray")
Im2 = np.array([[0.1,0.1],[0.1,0.1]])
plt.subplot(1, 2, 2)
plt.imshow(Im2, cmap="gray")
plt.show()
Thank you
You probably want to use the same Normalize
object on both subplots, like this:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import Normalize
Im1 = np.array([[0.1,0.2],[0.02,0.002]])
Im2 = np.array([[0.1,0.1],[0.1,0.1]])
_min = min(t.min() for t in [Im1, Im2])
_max = max(t.max() for t in [Im1, Im2])
norm = Normalize(vmin=_min, vmax=_max)
plt.subplot(1, 2, 1)
plt.imshow(Im1, cmap="gray", norm=norm)
plt.subplot(1, 2, 2)
plt.imshow(Im2, cmap="gray", norm=norm)
plt.show()