Linear Label on Logarithmic Plot
25 views (last 30 days)
Show older comments
Douglas Anderson
on 13 May 2021
Edited: Walter Roberson
on 14 May 2021
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 Comments
Walter Roberson
on 13 May 2021
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')
Accepted Answer
Walter Roberson
on 14 May 2021
ax = gca;
ax.YAxis.Exponent = 0;
2 Comments
Walter Roberson
on 14 May 2021
Edited: Walter Roberson
on 14 May 2021
% 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))
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!