Using loglog to plot results in a y axis that is not log scaled. But matlab seems to think it is

71 ビュー (過去 30 日間)
Hi, I've been trying to plot this data on a double log plot. However matlab seems to only produce a plot with the y axis on a linear scale instead of a log scale. And despite useing set(gca,'YScale','log') and all combinations of hold being on and off, nothing seems to work
I have tried both
frictiondata = [62118,11.037;59128,10.987;55209,10.919;49285,10.805;42407,10.655;35144,10.467;27427,10.219;17660,9.7791;10705,9.2785;8016,8.9892];
loglog(frictiondata(:,1),frictiondata(:,2),'ok')
set(gca,'YScale','log','XScale','log')
grid on
and
frictiondata = [62118,11.037;59128,10.987;55209,10.919;49285,10.805;42407,10.655;35144,10.467;27427,10.219;17660,9.7791;10705,9.2785;8016,8.9892];
hold on
loglog(frictiondata(:,1),frictiondata(:,2),'ok')
set(gca,'YScale','log','XScale','log')
grid on
But both versions of the plot give the same result shown in the figure below
Additionally, matlab seems to think that the y axis is on a log scale like the code would dictate. However, the y axis still appears to be on a linear scale on the genereated plot (again shown in the figure below).
I would also like to emphasize that a semilog plot would not be sufficient for my use.
Thank you very much for your time and effort!
  1 件のコメント
per isakson
per isakson 2019 年 12 月 10 日
編集済み: per isakson 2019 年 12 月 10 日
I think YScale actually is log and that the small range of your y-data makes it hard to observe it.
%%
frictiondata = [1.5,1.5; 10,10; 100,100; 0.7e3,0.7e3 ];
figure
loglog(frictiondata(:,1),frictiondata(:,2),'ok')
grid on
outputs

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 12 月 10 日
Your data is very nearly effectively linear in log x. sum((y-log(x)).^2) is 5.4E-7 -- a pretty low residual. You can do slightly better with 0.999927260504294 * log(x) - 0.000652400480442163 for a residue of 4.1E-7
Over that range of y values (8.9892 to 11.037), there is not much visual difference between log and linear. If you compare the two plots side by side you can see a bit of a difference in spacing of the ticks.

dpb
dpb 2019 年 12 月 10 日
編集済み: dpb 2019 年 12 月 10 日
Set
ylim([5 15])
to have sufficient part of the y-axis showing to be able to see the difference in the log scale vis a vis linear.
Just have too small a data range for it to be obvious with the limits you've got.
That's also 5K-80K on x axis.
Even here the difference isn't terribly obvious in the data range, but between the bottom and top of the graph range it's clear the y scale is logarithmic.
  1 件のコメント
Gregory Gassen
Gregory Gassen 2019 年 12 月 11 日
Great, Thank you, I ended up reallizing I was plotting the wrong data because of this. Again thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by