Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Histogram coloured by different hues in matlab

  1. Sep 11, 2013 #1
    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


  2. jcsd
  3. Sep 11, 2013 #2
    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook