Linear Label on Logarithmic Plot

24 ビュー (過去 30 日間)
Douglas Anderson
Douglas Anderson 2021 年 5 月 13 日
編集済み: Walter Roberson 2021 年 5 月 14 日
Hello!
I have an "example" regression loglog graph to show someone. The Y axis is not very large, but is less than 1, so it shows up as log rather than linear.
Is there a way to do this cleanly? Here's the code:
% reggie
rng('shuffle');
Intercept = 1000;
Slope = -1.6;
dist = 150:50:300;
vib = Intercept*(dist.^Slope);
minx = 50;
maxx = 400;
figure
loglog(dist,vib,'o','MarkerFaceColor','r')
xlim([minx maxx])
ylim([0.05 1])
hold on
grid on
grid minor
loglog([minx maxx],[Intercept*(minx^Slope) Intercept*(maxx^Slope)],'--');
xlabel('Distance (ft)');
ylabel('Vibration (in/s)');
title('Regression Example');
for n = 1:length(dist)
scatterling = 0.3 * vib(n);
median_value = vib(n);
new_values = scatterling.*randn(6,1)+median_value;
loglog(dist(n),new_values,'diamond','LineStyle','none');
end
newdist = 100;
reduction_factor = 0.65;
newvib = (reduction_factor * Intercept) *(newdist.^Slope);
loglog(newdist,newvib,'o','MarkerFaceColor','b');
scatterling = 0.4 * newvib;
median_value = newvib;
new_values = scatterling.*randn(6,1)+median_value;
loglog(newdist,new_values,'diamond','LineStyle','none','MarkerFaceColor','g');
Thanks!
Doug
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 5 月 13 日
It is not clear what you are asking for??
You do loglog plots. If you do not want to reprogram that to linear, you could
set(gca, 'YScale', 'linear')
Douglas Anderson
Douglas Anderson 2021 年 5 月 14 日
Thank you Walter.
I would like the scale to be logarithmic, but the label to be linear. For this case, it's basically from 0.05 to 1.0. So there wouldn't be a lot of points, but as it is, I get two labels: 10 superscript -1 and 10 superscript 0.
Thanks!
Doug

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 5 月 14 日
ax = gca;
ax.YAxis.Exponent = 0;
  2 件のコメント
Douglas Anderson
Douglas Anderson 2021 年 5 月 14 日
This made sense, but didn't work. Here's the results with that code added, both after the initial plot and at the end.
Tried also ax.YTick = [1 10], and that didn't work either.
Thank you, though! Any other thoughts?
Walter Roberson
Walter Roberson 2021 年 5 月 14 日
編集済み: Walter Roberson 2021 年 5 月 14 日
% reggie
rng('shuffle');
Intercept = 1000;
Slope = -1.6;
dist = 150:50:300;
vib = Intercept*(dist.^Slope);
minx = 50;
maxx = 400;
figure
loglog(dist,vib,'o','MarkerFaceColor','r')
xlim([minx maxx])
ylim([0.05 1])
hold on
grid on
grid minor
loglog([minx maxx],[Intercept*(minx^Slope) Intercept*(maxx^Slope)],'--');
xlabel('Distance (ft)');
ylabel('Vibration (in/s)');
title('Regression Example');
for n = 1:length(dist)
scatterling = 0.3 * vib(n);
median_value = vib(n);
new_values = scatterling.*randn(6,1)+median_value;
loglog(dist(n),new_values,'diamond','LineStyle','none');
end
newdist = 100;
reduction_factor = 0.65;
newvib = (reduction_factor * Intercept) *(newdist.^Slope);
loglog(newdist,newvib,'o','MarkerFaceColor','b');
scatterling = 0.4 * newvib;
median_value = newvib;
new_values = scatterling.*randn(6,1)+median_value;
loglog(newdist,new_values,'diamond','LineStyle','none','MarkerFaceColor','g');
yticklabels(compose("%g", yticks))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by