Vertically displace Data on a Log Graph

Hello, I have lots of data I would like to vertically displace for comparison. My yaxis values are between 1 and 0 dropping off exponentially and so y data is displayed on a log graph with error bars. The data is saved in many matrices named; x19946ALLTrans2 , x19946ALLTrans4, x19946ALLTrans6...
Here is my code:
figure1 = figure;
axes1 = axes('Parent',figure1,'YScale','log','YMinorTick','on');
box(axes1,'on');
hold(axes1,'all');
for i=4:2:18
hold on
dataname=strcat('x19946ALLTrans',num2str(i));
data=eval(dataname);
errorbar((data(:,1)),(data(:,2)),(data(:,3)))
xlabel('$Q(\AA^{-1})$','Interpreter','Latex','fontsize',18); ylabel('Reflectivity','FontSize',20);
legend1 = legend(axes1,'show');
set(legend1,'FontSize',14);
set(gcf,'Color','white');
hold on
end

Antworten (1)

Star Strider
Star Strider am 28 Nov. 2015

0 Stimmen

I would simply multiply them by the constant of your choice. That will vertically displace them on a semilogy plot. It should not affect the calculated values of the error bars, or their magnitude on the plot.
To illustrate:
x = 0:10;
y = 2*exp(-0.1*x) + 1;
figure(1)
semilogy(x, y)
errorbar(x, y, ones(size(x)))
hold on
semilogy(x, y*3)
errorbar(x, y*3, ones(size(x)))
hold off
axis([xlim 0 11])
grid

2 Kommentare

ShabirR
ShabirR am 28 Nov. 2015
Thanks!
My pleasure.
You can also just add an arbitrary constant to get the same effect:
x = 0:10;
y = 2*exp(-0.1*x) + 1;
figure(1)
semilogy(x, y)
errorbar(x, y, ones(size(x)))
hold on
semilogy(x, y+3)
errorbar(x, y+3, ones(size(x)))
hold off
axis([xlim 0 11])
grid

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Nov. 2015

Kommentiert:

am 28 Nov. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by