Could anyone help me how to plot the graph with respect to x axis in normal form and one y axis in semilog and other y axis in normal form.

3 Ansichten (letzte 30 Tage)
I am having the data in x,y1,y2
in graph i want to have x and y2 in normal and y1 should be in semilog.
When i used the command plotyy(x,y1,x,y2,'loglog')
all three appears to be in semilog
couly anyone help me how to make y1 alone in semilog and x and y2 in normal.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Mär. 2020
plotyy(x, y1, x, y2,'semilogy', 'plot')
  4 Kommentare
jaah navi
jaah navi am 21 Mär. 2020
It works.
Could you please help me to check with the following code:
x=1:5
y1=[ 3.5743 2.4635 1.6621 1.3403 0.5476 ];
y2=[3890000 4168000 4446000 4724000 4999000 ]
y3=[ 1.5543 1.1435 0.6421 0.2303 0.1476 ];
y4=[4190000 4454000 4718000 4982000 5346000 ]
figure
[hAx,hLine1,hLine2] = plotyy(x, y1, x, y2,@(X,Y)semilogy(X,Y,'k'), @(X,Y)plot(X,Y,'k'))
hold on;
[hAx,hLine3,hLine4] = plotyy(x, y3, x, y4,@(X,Y)semilogy(X,Y,'k'), @(X,Y)plot(X,Y,'k'))
when i run the above code the y axis value on the right is repeated more than one.
Could you please help me how to overcome it.
Walter Roberson
Walter Roberson am 21 Mär. 2020
plotyy() always creates a new right axes; one of the advantages of the newer yyaxis() is that it only creates the second axes if needed.
You do not want a new axes created; you want to re-use the existing ones.
x=1:5
y1=[ 3.5743 2.4635 1.6621 1.3403 0.5476 ];
y2=[3890000 4168000 4446000 4724000 4999000 ]
y3=[ 1.5543 1.1435 0.6421 0.2303 0.1476 ];
y4=[4190000 4454000 4718000 4982000 5346000 ]
figure
[hAx,hLine1,hLine2] = plotyy(x, y1, x, y2,@(X,Y)semilogy(X,Y,'k'), @(X,Y)plot(X,Y,'k'))
hold(hAx,'on');
plot(hAx(1), x, y3, 'k'); %axes is already set to semilogy
plot(hAx(2), x, y4, 'k');

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Two y-axis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by