could anyone help me how to avoid the repetition of y axis values on the right with respect to the following code

1 次查看(过去 30 天)
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'))
wheni run i can get the graph but y axis values on the right is occuring more than once.
Could anyone please help me how to avoid it.

采纳的回答

Rui Wang Wang
Rui Wang Wang 2020-3-21
%Make the scale range of the two graphs equal , I added four "set" to set the scale , and i suggest you set different colors .
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
[hAx1,hLine1,hLine2] = plotyy(x, y1, x, y2,@(X,Y)semilogy(X,Y,'k'), @(X,Y)semilogy(X,Y,'k'));
set(hAx1(1),'ylim',[0 5]);
set(hAx1(2),'ylim',[3890000 5346000 ]);
hold on;
[hAx2,hLine3,hLine4] = plotyy(x, y3, x, y4,@(X,Y)semilogy(X,Y,'k'), @(X,Y)semilogy(X,Y,'k'));
set(hAx2(1),'ylim',[0 5]);
set(hAx2(2),'ylim',[3890000 5346000 ]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by