问题
I would like to create a plot like pages 15/16:
comisef.eu/files/wps031.pdf
The example below gets close but only allows for symmetric error bars:
http://www.mathworks.com/matlabcentral/fileexchange/35294-matlab-plot-gallery-errorbar-plot/content/html/Errorbar_Plot.html
This example has asymmetric errorbars but only when plotted against the bar graph values bar with asymmetric error bounds in Matlab
Is it possible to have asymmetric errorbars like in the first example shown but without the need for the bar graph?
Thanks Baz
I also have a question where I try to achieve the same thing with boxplot but I'm not sure which (if indeed either of them can) can do it.
Matlab Boxplots
x = 1985:.05:2001; % x data
grad_ = rand(1,length(x))*.3; % graduated stuff
grad_2 = rand(1,length(x))*.3;
grad_3= rand(1,length(x))*.3;
h = subplot(1,3,1);
errorbar(grad_,x,grad_2,grad_3,'o');
axis(h, [0 0.6 1985 2001])
set(h, 'Ytick', x(1):x(end), 'Xtick', 0:.15:.6, 'YDir','reverse', 'YGrid', 'on');
xlabel('Gradient Search')
回答1:
The matlab function errorbar can create an asymmetric error bar and does not require a bar graph.
close all
x = 1:3;
y = [4 6 3];
lower = [1 4.5 0];
upper = [4.2 2 4];
errorbar(x, y, lower, upper, 'o')
回答2:
Here's what I came up with:
x = 1985:.05:2001; % x data
grad_ = rand(1,length(x))*.3; % graduated stuff
h = subplot(1,3,1);
plot(grad_,x); % flip x and y for vertical plot
axis(h, [0 0.6 1985 2001])
set(h, 'Ytick', x(1):x(end), 'Xtick', 0:.15:.6, 'YDir','reverse', 'YGrid', 'on');
xlabel('Gradient Search')
diff_ = rand(1,length(x)).^2 *.15; % differential stuff
h = subplot(1,3,2);
plot(diff_,x);
set(h,'yticklabel',[], 'Ytick', x(1):x(end), 'Xtick', 0:.15:.6, 'YDir','reverse', 'YGrid', 'on');
axis(h, [0 0.6 1985 2001])
xlabel('Differential Evolution')
delta_ = rand(1,length(x)).^2 *.2 - .2; % delta stuff
h = subplot(1,3,3);
plot(delta_,x);
set(h,'yticklabel',[], 'Ytick', [], 'Xtick', -.15:.15:.15, 'YDir','reverse', 'XGrid', 'on');
axis(h, [-.15 .15 1985 2001])
xlabel('\Delta of medians')
来源:https://stackoverflow.com/questions/20226879/how-to-plot-asymnmetric-errors-with-errorbar