Semilogy doesnt make my y axis logarithmic - R2017a

조회 수: 8 (최근 30일)
Emily Kernick
Emily Kernick 2018년 1월 4일
댓글: the cyclist 2018년 1월 5일
I have been asked to plot the temperature of a substance against time. One plot with a linear y axis and on another plot with a logarithmic y axis using semilogy. I do this and the graphs it plots don't appear to have a logarithmic axis.
code
%
end
  댓글 수: 1
the cyclist
the cyclist 2018년 1월 5일
OP deleted their code for some reason. Replicating it here:
s=[0,620,2266,3482]; %Creates an array of the times under 's'
c=[62,56,40,32]; %Creates an array of the temperatures under 'c'
figure()
subplot(1,2,1)
plot(s,c,'bo-') %Plots the first graph with a linear y axis
title('Plot using rectilinear scales')
xlabel('Time (seconds)')
ylabel('Temp (degrees celcius)')
grid
subplot(1,2,2)
semilogy(s,c,'ro-') %Plots the second graph on a logarithmic y axis
title('Plot using semilogy scales')
xlabel('Time (seconds)')
ylabel('Temp (degrees celcius)')
grid

댓글을 달려면 로그인하십시오.

답변 (2개)

the cyclist
the cyclist 2018년 1월 4일

It's subtle over such a small range of values, but that is actually a logarithmic axis. Notice that the spacing between the grid lines is a bit smaller at the top than at the bottom.

You can see the effect more clearly if you adjust the limits of the y-axis to be the same as in the linear-scale plot, using

ylim([30 65])

I've attached the result.


Star Strider
Star Strider 2018년 1월 4일
It is, actually. (I checked it by doing a linear plot of ‘log(c)’.) The y-axis range is so small that it’s difficult to see. However if you look at the linear distance between the ticks between 35 and 40, and compare them with the distance between 55 and 60, you will see the difference. The y-axis is definitely logarithmic.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by