Histogram coloured by different hues in matlab

In summary, the conversation is about a person seeking help with color-coding a histogram in MATLAB. One suggestion is to calculate the range of values and use it to determine the intensity of red for each point. However, this method may be complicated and there could be a simpler solution.
  • #1
physical101
47
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
  • #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.
 

What is a histogram in matlab?

A histogram in matlab is a graphical representation of data that shows the distribution of values in a dataset. It is a bar chart that displays the frequency or count of data points falling within certain ranges, or bins, of the data.

How do I create a histogram in matlab?

To create a histogram in matlab, you can use the histogram function. This function takes in a dataset as its input and automatically calculates the appropriate number of bins to display the data. You can also specify the number of bins or the bin edges to use for the histogram.

What is the purpose of colouring a histogram by different hues in matlab?

Colouring a histogram by different hues in matlab can help to visually distinguish different groups or categories within the data. This can be useful for identifying patterns or trends in the data, or for comparing distributions between different groups.

How do I colour a histogram by different hues in matlab?

To colour a histogram by different hues in matlab, you can use the histogram function with the FaceColor parameter. This parameter allows you to specify the colour or colours you want to use for the bars in the histogram. You can also use the FaceAlpha parameter to adjust the transparency of the bars.

Can I customize the colours used in a histogram in matlab?

Yes, you can customize the colours used in a histogram in matlab by specifying a custom colour palette for the FaceColor parameter. You can also use other colour-related parameters, such as EdgeColor and LineWidth, to further customize the appearance of the histogram.

Similar threads

  • Introductory Physics Homework Help
Replies
5
Views
1K
  • Sci-Fi Writing and World Building
2
Replies
52
Views
4K
  • Programming and Computer Science
Replies
1
Views
1K
  • Sci-Fi Writing and World Building
Replies
21
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
1K
Replies
19
Views
13K
Replies
16
Views
5K
  • STEM Career Guidance
Replies
5
Views
2K
  • Sci-Fi Writing and World Building
Replies
23
Views
8K
  • Sci-Fi Writing and World Building
Replies
1
Views
2K
Back
Top