简体   繁体   中英

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. Currently, my data is in the form of 3 separate arrays all of the same length. One array has x-coordinates, another has y-coordinates, and the third has numerical values that are the intensities i wish to colorize. 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. Maybe this is an issue with the x and y arrays being 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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