Using loglog to plot results in a y axis that is not log scaled. But matlab seems to think it is
58 次查看(过去 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
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
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.
0 个评论
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!