How to evenly space the y-axis from 1 to 10^-3?
1 view (last 30 days)
Show older comments
Hello, I have tried multiple ways to try and get the y axis to be evenly distributed where the top is 1 and the bottom is 10^-3. However I cannot figure it out. The resulting graph from my code returns a plot where there is a big gap between y=1 and y=0.1, then 0.01 and 0.001 are overlapping at the bottom. I appreciate any help! I have attached my code for reference.
Kc_07_012 = [0.023902439 0.039634146 0.066341463 0.053902439 0.009158537 0.002829268]; % y-values extracted from plot
Kc_06_02 = [0.102186235 0.099635628 0.092348178 0.095991903 0.094545455 0.093076923 0.084696356 0.073765182 0.065384615 0.023846154];
Kc_006_07 = [0.686363636 0.831818182 0.636363636 0.3 0.082145749 0.061012146 0.044251012 0.019473684 0.01437247 0.005148148 0.001555556];
x_07_012= [0.11282051282051282, 0.19282051282051282, 0.28923076923076924, 0.49435897435897436, 0.601025641025641, 0.6871794871794872];
x_006_07= [0.057435897 0.118974359 0.235897436 0.358974359 0.475897436 0.527179487 0.54974359 0.601025641 0.603076923 0.658461538 0.701538462];
x_06_02=[0.244102564 0.326153846 0.295384615 0.369230769 0.395897436 0.428717949 0.49025641 0.502564103 0.516923077 0.598974359];
plot(x_07_012,Kc_07_012,'.')
hold on
plot(x_06_02,Kc_06_02,'o')
plot(x_006_07,Kc_006_07,'^')
xlim([0 0.8])
% Set the y-axis limits
ylim([1e-3, 1])
% Set the y-axis tick locations
yticks(double([0.001, 0.01, 0.1, 1]))
0 Comments
Answers (1)
Steven Lord
on 7 Apr 2023
Do you want a logarithmic Y axis? If so use semilogy or loglog (if you want both axes in log scale) instead of plot. Alternately store the handle of the axes (or retrieve it from the plot handle using ancestor) and set its YScale property to 'log'.
x = 1:10;
y = x.^2;
figure
semilogy(x, y)
figure
loglog(x, y)
figure
h = plot(x, y);
ax = ancestor(h, 'axes');
ax.YScale = 'log';
0 Comments
See Also
Categories
Find more on Log 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!