How to evenly space the y-axis from 1 to 10^-3?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Steven Lord
2023년 4월 7일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Log Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


