Need help making a stacked bar chart
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey all.
I have some data that I need plotted in a stacked bar chart. X-axis should have a bin size from -1 to 1 with an interval of 0.1, and the y-axis is frequency. Each piece of data needs to be in a different color to denote what day the data comes from.
I am having issues stacking the bar chart. What I see happening is after plotting the first data (in red), the second data set (in blue) overlaps the red, not stacking it. I have 6 data sets to plot, and by the end, it's all overlapped by the 6th data set (which has frequencies much higher than the earlier data sets.
Here's my code to start. I'll post the first three data sets.
y1 = july17(:, 9);
y2 = july19(:, 9);
y3 = july24(:, 9);
% Creates bin sizes for stacked bar chart
nbins = (-1:0.1:1);
% Creates "stacked" bar chart by day (denoted in different colors)
[counts_1, edges_1] = hist(y1, nbins);
bar(edges_1, counts_1, 'r')
hold on
[counts_2, edges_2] = hist(y2, nbins);
bar(edges_2, counts_2, 'b')
hold on
[counts_3, edges_3] = hist(y3, nbins);
bar(edges_3, counts_3, 'g')
To better illustrate what I need, think of it like this. Suppose my data with correlation from -0.9 to -1.0 has a frequency of 7 (july 17 data in red). Then for july 19, there is a frequency of 10 in the same correlation interval. I need it to start from 7 and go up to 17, not from 0 to 10 (where the red would be covered up). Any and all ideas welcome. Thanks :)
0 Kommentare
Antworten (1)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!