Azzera filtri
Azzera filtri

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

6 visualizzazioni (ultimi 30 giorni)
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?
Thanks in advande,
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';

Risposta accettata

Voss
Voss il 27 Nov 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';

Più risposte (1)

Voss
Voss il 27 Nov 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';

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by