【发布时间】:2021-09-22 19:39:40
【问题描述】:
我想在图片上放一个 pcolor 图表。你知道一种自动匹配/调整颜色映射到图片的方法吗?
示例代码:
import matplotlib.pyplot as plt
import numpy as np
# my image
im = plt.imread('salad.png')
# example pcolor chart
values = np.random.rand(6, 10)
p = plt.pcolor(values)
图片:
P色图:
我试过了:
# Create Figure and Axes objects
fig,ax = plt.subplots(1)
# display the image on the Axes
implot = ax.imshow(image)
# plot the pcolor on the Axes. Use alpha to set the transparency
p = ax.pcolor(values, alpha = 0.5, cmap='viridis')
# Add a colorbar for the pcolor field
fig.colorbar(p, ax=ax)
因此,我在下面有这个,这不是我想要的。颜色图不适合整个图像范围:
有没有办法自动将 pcolor 图表调整为图像大小?还是图片到 pcolor 图表大小?
我的意思是这样的示例结果:
提前感谢您的任何想法。
【问题讨论】:
标签: python image matplotlib