how to extract colour percentages of contour plot
1 view (last 30 days)
Show older comments
hi, output of my data set is 5x15 matrix, with this a contourf was plotted. the plot displays differnt colous since i used contourf command. so, i would like to know percentage of each colour which present in the plot, i tried using impixel command.but i failed to use this command. is there any other way to use .. please help me...
0 Comments
Answers (2)
Walter Roberson
on 1 Jul 2017
You could do a screen capture and have it do calculations on the color image you obtained that way.
Consider the possibility that you do not really care what the colors are, and that instead what you want to know is the area occupied by each contour level. That is a different question which can be answered by using histcounts() with your data and the vector of the contour levels
2 Comments
Image Analyst
on 1 Jul 2017
I agree, histcounts() is most likely what you're needing. Did you see the documentation?
[counts, binEdges] = histcounts(data, binEdges);
is one way to call it. There are several ways it can be used. Just look in the help.
Star Strider
on 1 Jul 2017
To get the area occupied by each contour level, it might be easier to use the 'ContourMatrix' (link) property of contourf. (See the documentation on Contour Properties (link) for details.) You will have to search through the vectors for the individual levels, since they define the beginning of each contour (x,y) matrix. Getting those from the 'LevelList' (link) property first makes this easier. Then use the trapz (link) function to do the integration.
Note that you need to integrate all the contours and then subtract the areas of the inner contours to get the correct values of the outer contours.
This is not difficult, but does require some programming. Since the (x,y) contour matrices are not all the same lengths, use a cell array to store them. (You will need to loop through them to isolate all of them first.)
0 Comments
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!