Linear Label on Logarithmic Plot

23 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by