# While using "hold on" to create a graph with multiple graphs together, the logarithmic scale on x axis is not applied.

3 visualizaciones (últimos 30 días)
João Sá Pereira el 27 de Nov. de 2023
Comentada: Voss el 27 de Nov. de 2023
I want to create a multiple graph using a logarithmic scale on the x-axis, to be able to see the differences between the different values on y-axis. Altough the scale on x-axis is linear and not logarithmic. Is there another way to do what I intend, using a different function?
Here's the code i used:
pi_1=[1 1 0.643 0.472 0.371 0.297]';
pi_08=[1 1 0.632 0.467 0.367 0.295]';
pi_05=[1 1 0.614 0.459 0.362 0.291]';
pi_01=[1 1 0.588 0.448 0.354 0.285]';
s=[3.394 2.400 1.697 1.200 0.849 0.600]';
figure(1)
hold on
cum1=semilogx(s, pi_1);
cum08=semilogx(s,pi_08);
cum05=semilogx(s, pi_05);
cum01=semilogx(s, pi_01);
hold off
xlabel('Calibre, mm');
ylabel('Pi');
grid on
title('Cumulante Produto Final')
legend('Pa=1.000','Pa=0.800','Pa=0.500','Pa=0.100');
cum1.LineStyle = '-';
cum1.Color = 'blue';
cum1.Marker = 'o';
cum08.LineStyle = '-';
cum08.Color = 'red';
cum08.Marker = 'o';
cum05.LineStyle = '-';
cum05.Color = 'green';
cum05.Marker = 'o';
cum01.LineStyle = '-';
cum01.Color = 'magenta';
cum01.Marker = 'o';
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Voss el 27 de Nov. de 2023
One way to fix this is to set the 'XScale' of the axes to 'log' explicitly.
pi_1=[1 1 0.643 0.472 0.371 0.297]';
pi_08=[1 1 0.632 0.467 0.367 0.295]';
pi_05=[1 1 0.614 0.459 0.362 0.291]';
pi_01=[1 1 0.588 0.448 0.354 0.285]';
s=[3.394 2.400 1.697 1.200 0.849 0.600]';
figure(1)
set(gca(),'XScale','log') % this can go anywhere from this line down
hold on
cum1=semilogx(s, pi_1); % these can be plot() or semilogx() now
cum08=semilogx(s,pi_08);
cum05=semilogx(s, pi_05);
cum01=semilogx(s, pi_01);
hold off
xlabel('Calibre, mm');
ylabel('Pi');
grid on
title('Cumulante Produto Final')
legend('Pa=1.000','Pa=0.800','Pa=0.500','Pa=0.100');
cum1.LineStyle = '-';
cum1.Color = 'blue';
cum1.Marker = 'o';
cum08.LineStyle = '-';
cum08.Color = 'red';
cum08.Marker = 'o';
cum05.LineStyle = '-';
cum05.Color = 'green';
cum05.Marker = 'o';
cum01.LineStyle = '-';
cum01.Color = 'magenta';
cum01.Marker = 'o';
##### 2 comentariosMostrar NingunoOcultar Ninguno
João Sá Pereira el 27 de Nov. de 2023
Tanhk you, it worked perfectly!!
Voss el 27 de Nov. de 2023
You're welcome!

Iniciar sesión para comentar.

### Más respuestas (1)

Voss el 27 de Nov. de 2023
One way to fix this is to put the hold on afer the first semilogx() call.
pi_1=[1 1 0.643 0.472 0.371 0.297]';
pi_08=[1 1 0.632 0.467 0.367 0.295]';
pi_05=[1 1 0.614 0.459 0.362 0.291]';
pi_01=[1 1 0.588 0.448 0.354 0.285]';
s=[3.394 2.400 1.697 1.200 0.849 0.600]';
figure(1)
cum1=semilogx(s, pi_1);
hold on
cum08=semilogx(s,pi_08);
cum05=semilogx(s, pi_05);
cum01=semilogx(s, pi_01);
hold off
xlabel('Calibre, mm');
ylabel('Pi');
grid on
title('Cumulante Produto Final')
legend('Pa=1.000','Pa=0.800','Pa=0.500','Pa=0.100');
cum1.LineStyle = '-';
cum1.Color = 'blue';
cum1.Marker = 'o';
cum08.LineStyle = '-';
cum08.Color = 'red';
cum08.Marker = 'o';
cum05.LineStyle = '-';
cum05.Color = 'green';
cum05.Marker = 'o';
cum01.LineStyle = '-';
cum01.Color = 'magenta';
cum01.Marker = 'o';
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Line Plots en Help Center y File Exchange.

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by