[英]How to Make a Color Map for plt.imshow() be set to the same values on two different plots
正如imshow
指出的, imshow
使用關鍵字vmin
和vmax
來控制顏色圖的比例。 您可以使用get_clim()
方法獲取第一個圖的(自動確定的)值:
# Create your first plot
img = plt.imshow(nonfour, cmap='gray')
# Extract vmin and vmax
vmin, vmax = img.get_clim()
# Create your second plot using these limits
plt.imshow(np.abs(four), cmap='gray', vmin=vmin, vmax=vmax)
另外,您也可以使用set_clim()
方法:
img = plt.imshow(nonfour, cmap='gray')
img2 = plt.imshow(np.abs(four), cmap='gray')
img2.set_clim(img.get_clim())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.