Why does pcolor output a mirrored array in this example?

后端 未结 1 720
夕颜
夕颜 2021-01-28 19:25
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?

相关标签:
1条回答
  • 2021-01-28 19:54

    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. by flipping the y-axis

      plt.gca().invert_yaxis()

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

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

    0 讨论(0)
提交回复
热议问题