[英]Fill section of contour with solid color
看看matplotlib
轮廓图和颜色图演示。 在等高线图演示的最后一个示例中,您可以为等高线图指定一个颜色图,如下所示
plt.figure()
# plots a bunch of colours
im = plt.imshow(Z, interpolation='bilinear', origin='lower',
cmap=cm.gray, extent=(-3, 3, -2, 2))
# plot the contour lines
levels = np.arange(-1.2, 1.6, 0.2)
CS = plt.contour(Z, levels,
origin='lower',
linewidths=2,
extent=(-3, 3, -2, 2))
如果要将某些区域保留为白色/未填充,则需要定义自己的颜色图。 颜色图只是将数值映射到颜色的dict
https://matplotlib.org/examples/pylab_examples/contour_demo.html
https://matplotlib.org/examples/pylab_examples/custom_cmap.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.