简体   繁体   English

使用Python在xy坐标上绘制颜色贴图

[英]Plotting a color map with x y coordinates in Python

hoping this question is an easy one to solve! 希望这个问题很容易解决!

I am trying to create an intensity map of a set of values. 我正在尝试创建一组值的强度图。 Each value has a corresponding (x,y) coordinate. 每个值都有一个对应的(x,y)坐标。 Currently, my data is in the form of 3 separate arrays all of the same length. 目前,我的数据采用3个独立阵列的形式,长度相同。 One array has x-coordinates, another has y-coordinates, and the third has numerical values that are the intensities i wish to colorize. 一个阵列具有x坐标,另一个具有y坐标,第三个阵列具有我想要着色的强度的数值。 Really I'm thinking this is just a scatter plot but integrating the third array's value into a color. 真的,我认为这只是一个散点图,但将第三个数组的值整合为一种颜色。 If anyone knows which plotting method I should use that would be great. 如果有人知道我应该使用哪种绘图方法会很棒。 I've tried pcolor from pyplot, but it is giving me errors about the dimensions of my x and y data. 我从pyplot尝试了pcolor,但它给了我关于我的x和y数据的维度的错误。 Maybe this is an issue with the x and y arrays being 1-d? 也许这是x和y数组为1-d的问题?

Thanks in advance for any help! 在此先感谢您的帮助!

Figured it out! 弄清楚了! Just need to set the value array to a color variable. 只需要将值数组设置为颜色变量。 Like this: 像这样:

    plt.scatter(x, y, c=z, cmap='jet',vmin=0, vmax=250)
    plt.colorbar()
    plt.show()

"z" is the values array! “z”是值数组!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM