Two Histograms on the same graph with a curved line
17 views (last 30 days)
Show older comments
Hello, I'm not sure where to to start with this problem so I'm asking the quesiton first for recommendations on where to start.
Essentially..
I have three graphs in one. there will be a line graph i can plot using the plot(x) function. However Underneath each of the points in the line graph i need to plot two histograms (one on top of the other). Essentially, if a point on the line graph is x=1, y=100, then the two histograms visualize the components to make y = 100.
e.g. Line Graph Point (1,100), Histogram 1 Point (1, 75), Histogram 2 Point (1, 25). Alternatively, Line Graph Point (1,100), Histogram 1 Point (1, -25), Histogram 2 Point (1, 125).
Either way the ylinegraph = yhistogram1 + yhistogram2 , and xlingegraph = xhistogram1 = xhistogram2.
I have approximately 500-100 points to plot per graph im doing.
Any suggestions on where to start would be greatly appreciated.
- Kyle
0 Comments
Accepted Answer
Star Strider
on 29 Jan 2015
You don’t provide enough information or code to respond specifically, so I’ll provide an example:
Data = randi(25, 10,2); % Create Data For ‘bar’ Plot
Line = [0:0.5:5].^2; % Create Line Plot Data
figure(1)
bar(Data, 'Grouped') % Plot Histogram Using ‘bar’
hold on
plot([0:10], Line, 'LineWidth',1.5) % Plot Line
hold off
2 Comments
Star Strider
on 29 Jan 2015
My pleasure.
To plot the histograms on top of each other, consider using the 'Stacked' option instead of 'Grouped':
bar(Data, 'Stacked') % Plot Histogram Using ‘bar’
More Answers (0)
See Also
Categories
Find more on Histograms 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!