How to get pixel value from a color map?

Click For Summary
SUMMARY

The discussion focuses on extracting individual mass values from a scatter plot generated using Python's Matplotlib library. The user utilizes two 1D arrays, HC and OC, to create a hexbin plot with a color map. The primary question is how to retrieve the mass values corresponding to specific pixel points on the plot, given the absence of direct mass data in the provided arrays. The solution involves understanding the mapping of colors to mass values within the context of the hexbin plot.

PREREQUISITES
  • Proficiency in Python programming
  • Familiarity with Matplotlib version 3.0 or higher
  • Understanding of hexbin plots and color mapping
  • Knowledge of data normalization techniques
NEXT STEPS
  • Explore how to use Matplotlib's color normalization functions
  • Learn about retrieving data from hexbin plots in Matplotlib
  • Investigate the use of scatter plots for visualizing multidimensional data
  • Study the implementation of color maps in data visualization
USEFUL FOR

Data scientists, Python developers, and anyone involved in data visualization who seeks to enhance their understanding of extracting values from graphical representations in Matplotlib.

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.