Log axis on plots of different types

조회 수: 2 (최근 30일)
jnaumann
jnaumann 2014년 2월 6일
답변: Richard 2014년 2월 6일
I am trying to create a plot whereby I have 4 curves made up of a number of points connected by a spline. I have managed to create the the plot normally but want to change the y-axis scale to be logarithmic.
I have tried using scatter, hold on, semilogy etc... and also axes('yscale','log') but the first attempt just generates standard plots whereas the second one creates one large plot in the figure (I am trying to use subplots).
Any ideas?
Many thanks in advance
Jack

답변 (2개)

Mischa Kim
Mischa Kim 2014년 2월 6일
편집: Mischa Kim 2014년 2월 6일
As an example of using subplots (I believe that's what you are asking for):
x = linspace(1,10,200);
y = x.^2;
figure
subplot(2,1,1)
semilogy(x,y)
subplot(2,1,2)
loglog(x,y)

Richard
Richard 2014년 2월 6일
If you already have a set of axes with a plot in them then you need to explicitly set the y-axis on the existing axes handle:
hAxes = gca; % Or use the axes handle if you have it
set(hAxes , 'YScale', 'log');

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by