Plotyy and error bars
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'd like to do a plotyy function, and I have confidence intervals for each point of my data. I can't seem to figure out a way to do both of these at once. My x data is stored in an array RC, and the two y data are in arrays L and D. The confidence intervals are in ciL and ciD, and are not necessarily symmetric. Is there an easy way to add these as error bars to my plot?
2 Kommentare
Jan
am 3 Aug. 2011
If you post the code you have currently, it would be easier to insert the changes.
Akzeptierte Antwort
Patrick Kalita
am 3 Aug. 2011
When customizing graphs made with plotyy, it is usually useful to store axes handles that it provides as its return value. With those axes handles you can (1) turn hold mode on for each one and (2) add errorbars to each.
Here's an example:
% Make up some data to plot
x = 1:5;
y1 = rand(1,5);
y2 = rand(1,5) + 100;
L1 = 0.01 * ones(1,5);
U1 = 0.02 * ones(1,5);
L2 = 0.03 * ones(1,5);
U2 = 0.04 * ones(1,5);
% Store the axes handles produced by PLOTYY
ax = plotyy(x, y1, x, y2);
% Use HOLD and ERRORBAR, passing axes handles to the functions.
hold(ax(1), 'on');
errorbar(ax(1), x, y1, L1, U1);
hold(ax(2), 'on');
errorbar(ax(2), x, y2, L2, U2);
2 Kommentare
Patrick Kalita
am 8 Aug. 2011
No, that's not the way ERRORBAR wants its lower and upper bounds. I guess you'll have to convert.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Two y-axis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!