Matplotlib均匀间隔的轮廓线

时间:2015-10-10 23:53:23

标签: python matplotlib plot

我正在学习如何使用轮廓功能,我被赋予了使用第4个参数绘制25个均匀间隔线的任务。

编辑: 这是所需的图像: enter image description here

z = np.load('heights.npy')
plt.contour(np.transpose(z), 25) #Now plotting with 25 evenly spaced contours
plt.title('even contour lines')
plt.savefig('myFig2.png', format='png')

enter image description here

我已经检查了here,但我找不到我需要的东西。任何帮助将不胜感激。

我也看了here但你看,我的线条间距不均匀。

1 个答案:

答案 0 :(得分:3)

您需要手动指定地块的等级,否则matplotlib将为您确定等级,这显然不是您想要的等级。

z = np.load('heights.npy')
plt.contour(np.transpose(z),np.linspace(z.min(),z.max(),25)) 
plt.title('even contour lines')
plt.savefig('myFig2.png', format='png')

这将设置contour级别,使其将z数据的范围除以24个等距间隔,得到25行。

相关问题