Histogram coloured by different hues in matlab

  • Context: MATLAB 
  • Thread starter Thread starter physical101
  • Start date Start date
  • Tags Tags
    Histogram Matlab
Click For Summary
SUMMARY

To create a histogram in MATLAB that transitions from black to red based on intensity values, users can calculate the range of values and relate each point to the intensity of red. By defining the color specification for red as [1 0 0] and adjusting each value incrementally based on its position within the total range, users can achieve the desired color gradient. While this method may seem cumbersome, it effectively allows for individual point color coding in the histogram.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of histogram data representation
  • Knowledge of RGB color specifications in MATLAB
  • Basic grasp of functions and loops in MATLAB
NEXT STEPS
  • Explore MATLAB's built-in histogram functions for advanced customization
  • Learn about MATLAB's colormap functions for gradient color applications
  • Investigate creating custom functions in MATLAB for repetitive tasks
  • Research techniques for visualizing data with color gradients in MATLAB
USEFUL FOR

This discussion is beneficial for MATLAB users, data visualizers, and physicists looking to enhance their histogram visualizations with color gradients based on intensity values.

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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 52 ·
2
Replies
52
Views
8K
  • · Replies 19 ·
Replies
19
Views
14K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 21 ·
Replies
21
Views
5K
  • · Replies 16 ·
Replies
16
Views
7K
Replies
23
Views
9K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K