Vertically displace Data on a Log Graph
Mostrar comentarios más antiguos
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
Respuestas (1)
Star Strider
el 28 de Nov. de 2015
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 comentarios
ShabirR
el 28 de Nov. de 2015
Star Strider
el 28 de Nov. de 2015
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
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!