如何制作非正方形轮廓线 [英] How to make a non-square contourf-plot

查看:71
本文介绍了如何制作非正方形轮廓线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在pyplot中使用contourf绘制一些标量数据,但是当我的域为非正方形时,我感觉数据显示不正确,因为它总是将其绘制为正方形(尽管轴值在一侧会更快地增加.) 如何强制轴缩放相等,以便如果我的域在 x 方向上是两倍长,则图像实际上绘制在具有此属性的矩形中?

I'm using contourf in pyplot to plot some scalar data, but when my domain is non-square i feel like the data is misrepresented because it always plots it in a square (though the axis values will increase faster on one side.) How can i force the axis scaling to be equal, such that if my domain is twice as long in the x-direction the image is actually plotted in a rectangle with this property?

我正在做这样的事情:

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
contour = ax.contourf(X,Y,Z)
fig.colorbar(contour)
fig.canvas.draw()

推荐答案

这可能会有所帮助:

ax = fig.add_subplot(111, aspect="equal")

这篇关于如何制作非正方形轮廓线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆