Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

semilog plots with hold on

If I try to plot multiple plots with a logarithmic axis, the log scale is disabled. If I remove the hold on the log scale is enabled, but I can only plot a single plot.

figure(1); clf
x = linspace(0,1,100);
y = exp(-x);

hold on;
semilogy(x, y);
semilogy(x, 2*y);
hold off;

Why?, How can I create multiple log scale plots?

like image 667
Matthias Pospiech Avatar asked Feb 28 '12 07:02

Matthias Pospiech


1 Answers

Your code works already in octave (and I don't have matlab at this computer), but I think the problem is that you do hold on before the first plot, hence preventing the initial axis to be created. try this:

figure(1); clf
x = linspace(0,1,100);
y = exp(-x);

semilogy(x, y);
hold on;
semilogy(x, 2*y);
hold off;
like image 126
Johan Lundberg Avatar answered Oct 11 '22 13:10

Johan Lundberg