How can I set the y axis scale to the square root as this graph here? I tried set(gca, 'yscale', 'lsqrt') but it didnt work!!!
thanks in advance

 채택된 답변

Star Strider
Star Strider 2021년 2월 5일

0 개 추천

Experiment with this approach to get the result you want:
x = 0:100;
y = rand(size(x))*512;
figure
plot(x, y, '.')
grid
yt = [0 2.^(0:ceil(log2(max(y))))];
set(gca, 'YTick',yt, 'YScale','log')
.

댓글 수: 2

Nuno Fahla
Nuno Fahla 2021년 2월 5일
its not exactly what I wanted but its pretty good, thank you star strider. Please not in the original graph values go up to 1000, while mine go only to 100.
As always, my pleasure!
I am not certain how to interpret the rest of your Comment. If you want to limit the y-axis to the next power of 2 that is greater than the maximum value of your data, the nextpow2 function can likely do what you want. (I did not use it in my posted code because I was not certain what the eventual desired result would be.)
Also, experiment with omitting (turning off) the minor ticks and associated minor grid lines, if you do not want them to be displayed:
set(gca, 'YTick',yt, 'YScale','log', 'YMinorTick','off', 'YMinorGrid','off')
You can also set the ylim range (minimum and maximum values) to be what you want.
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Axes Appearance에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2021년 2월 5일

댓글:

2021년 2월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by