在此示例中,为什么pcolor输出一个镜像数组? [英] Why does pcolor output a mirrored array in this example?

查看:55
本文介绍了在此示例中,为什么pcolor输出一个镜像数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

array = np.eye(5)
plt.pcolor(array)

如果要执行此代码,则输出图实际上将是已定义数组的镜像.为什么呢?

If you were to do this code, the output graph would actually be a mirror of the defined array. why is that?

推荐答案

它只是从左下角绘制的,如果您查看x& y轴上的标签,这是很有意义的.查看文档您可以将其反转:

It just draws from the bottom left, which make quite sense if you check out the labeling on the x&y-axes. Check out documentation You can invert it though:

  1. 通过翻转y轴

  1. by flipping the y-axis

plt.gca().invert_yaxis()

或通过更改输入矩阵(如果适用的话...)

or by changing your input matrix (if appropriate ...)

plt.pcolor(np.eye(5)[::-1,:])

这篇关于在此示例中,为什么pcolor输出一个镜像数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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