Linear Label on Logarithmic Plot
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Douglas Anderson
le 13 Mai 2021
Modifié(e) : Walter Roberson
le 14 Mai 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 commentaires
Walter Roberson
le 13 Mai 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')
Réponse acceptée
Walter Roberson
le 14 Mai 2021
ax = gca;
ax.YAxis.Exponent = 0;
2 commentaires
Walter Roberson
le 14 Mai 2021
Modifié(e) : Walter Roberson
le 14 Mai 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))
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!