Histogram coloured by different hues in matlab

  • Context: MATLAB 
  • Thread starter Thread starter physical101
  • Start date Start date
  • Tags Tags
    Histogram Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
physical101
Messages
41
Reaction score
0
Dear Physics fans,

Are we all okay? I hope so.

I was wondering if you could help me please?

I am banging my head against a wall in MATLAB and I think what I need to do should be very easy.

I have a histogram of intensities and I could like to colour then starting off at black and getting progressively closer to red as it reaches the maximum.

Any advice, hints or tips you could give would be lovely

Cheers

Duane
 
Physics news on Phys.org
One thing I think you could do but it seems very janky since it would be color coding each point individually (technically). You could have MATLAB calculate the range of your values and how many values there are and then relate each point to the intensity of red. For example you have 100 values ranging from 0-100, the color specification for red is [1 0 0] so have each value go at increments of 1/100; therefore, you could have the intensity equal to something like this [v/r 0 0] where v is the value of the point and r is the total range. You could turn this into a function and have this specified for each point, it should give you the change in color like you want but it seems like a big hassle and there should be an easier way out there that I don't know about.