MATLAB: Two Histograms on the same graph with a curved line

histogramsline graphoverlapping graphsscatter

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

Best Answer

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
Related Question