Hi, I am trying to plot points, with the x-axis in log scale.
This is my code
ss0 = readtable('MedianBeta.xlsx')
x = ss0{:,2}
y1= ss0{:,3}
y2= ss0{:,4}
y3= ss0{:,5}
y4= ss0{:,6}
scatter(x,y1,'r')
hold on
%scatter(x,y2,'k')
%hold on
%scatter(x,y3,'m')
%hold on
%scatter(x,y4,'g')
%hold on
set(gca,'xscale','log')
title('Median and Catch')
xlabel('Median')
ylabel('Beta')
It seems simple enough. However, the plot I get is not the logarithmic, with 10^0, 10^1, etc..., that I was looking for (Yet, when I reverse it and set y-axis as log, it does go with the traditional scale of 10^0, 10^1, 10^2, etc. It is just not doing it with the x-axis)
Also, there becomes a point at 0 on the x axis, which is inaccurate. There are no zero values for Median.
Something is off. I'd appreciate any help.
Thank you

 채택된 답변

Star Strider
Star Strider 2020년 6월 23일

0 개 추천

The plot is working correctly. To more easily see that it is, add this xlim call (temporarily):
xlim([0.01 10]*1E+5)
.

댓글 수: 6

CMatlabWold
CMatlabWold 2020년 6월 23일
Thank you! Why do you say "temporarily"?
Star Strider
Star Strider 2020년 6월 24일
As always, my pleasure!
Use it ‘temporarily’ only to demonstrate that the scaling works as you want it to. Otherwise, it distorts the plot.
CMatlabWold
CMatlabWold 2020년 6월 24일
Oh I see. Thanks again!
By the way, do you know how I can just create a straight horizontal line at y = 0?
As always, my pleasure!
If you have R2018b or later, you can use yline:
yline(0, 'r', 'LineWidth',2);
and with all releases, this works:
plot(xlim, [0 0], '-r', 'LineWidth',2)
Set the LineWidth and linestyle properties to be what you want. I enlarged it here so I could see it easily (since the lower y-limit is 0).
CMatlabWold
CMatlabWold 2020년 6월 25일
Thank you!
Star Strider
Star Strider 2020년 6월 25일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Log Plots에 대해 자세히 알아보기

제품

질문:

2020년 6월 23일

댓글:

2020년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by