How to plot multiple horizontal bar plots in single figure?
Show older comments
Hi, I want to plot several bar plot or histograms on a line which are to represent the uncertainty of the data.
My problem is establishing the baseline for my bar plots. As I want them to be located different place, I need different baselines. But the basevalue option for my last bar plot seems to effect the basevalue of all the previous basevalues set.
The following example code below results in the figure to the left. While what I want is to get the right figure.
So how can I assign the Basevalue proberly to get the right figure?
% Some data
X = [1 100];
Y = [5 7.58];
A = normrnd(0,0.2,[1 1000])+7.5;
B = normrnd(1,0.2,[1 1000])+5;
[counts50,bins50] = hist(A,20);
[counts5,bins5] = hist(B,20);
figure()
hold on
plot(X,Y,'-'); % Plot of line
% Horizontal bar plot baseline 50
barh(bins50,50+counts50*0.5,'BarWidth',1,'Basevalue',50,'FaceColor','none','ShowBaseLine','off'); % Plot of histogram
% Horizontal bar plot basline 5
barh(bins5,5+counts5*0.05,'BarWidth',1,'Basevalue',5,'FaceColor','none','ShowBaseLine','off'); % Plot of histogram
% Options
set(gca,'FontSize',20,'XScale','log');
xticks([1 5 50 100]);
yticks=(5:8);
grid on

Accepted Answer
More Answers (0)
Categories
Find more on Data Distribution 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!
