Python How to get pixel value from a color map?

Click For Summary
To extract individual mass values at specific pixel points from a scatter plot generated using two 1D arrays in Python, the discussion centers on the need to correlate the plotted data with corresponding mass values. The user has provided code that utilizes hexbin for plotting and a colorbar for normalization, but seeks clarity on how to retrieve mass values at the plotted locations. The focus is on determining whether the goal is to display mass values directly on the plot or to obtain the color assignments based on mass values. The conversation emphasizes the importance of linking the plotted data points to their respective mass values for accurate representation and analysis.
Atr cheema
Messages
67
Reaction score
0
I have a python code where it generates two 1D arrays, plots them using scatter plot and then draws colorbar using normalization range. How can I find individual values at those individual pixel points?

Python:
HC = data["HC"]
OC  = data["OC"]
sample = y
widthmm, heightmm = 171, 233
ratio = (widthmm/2.0)/(heightmm/4.0)
widthinch = widthmm/25.40
fig = plt.figure(figsize=(widthinch,widthinch/ratio))
ax1 = fig.add_subplot(111)
ax1 = plt.hexbin(OC,HC,cmap=glocmap,bins=None,gridsize=(20,15),alpha=0.75,mincnt=1,vmax=50,linewidth=0,vmin=7)

CvarLab = 0
cb = plt.colorbar(ax1)
cb.set_label(CvarLab,size=20)
cb.ax.tick_params(labelsize=20)
cb.set_alpha(1)
cb.draw_all()

and it generates a plot like this .My question is how can I find values of 'Mass' on those individual points shown in image given than we have only two 1 dimensional arrays?
 
Technology news on Phys.org
What is it you're wanting to do? is it to show the mass values on the plot? or to get the colors the mass values were assigned?
 
jedishrfu said:
What is it you're wanting to do? is it to show the mass values on the plot? or to get the colors the mass values were assigned?
I want to get mass values at those individual points on the plot.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...