y-axis only absolute values

조회 수: 15 (최근 30일)
Samuel
Samuel 2014년 6월 13일
댓글: dpb 2014년 6월 13일
Hi folks,
Is there a easy way to set the y-axis values to their absolute values such that there are only positive numbers on the y-axis?
Thank you for answers,
Cheers Sam
  댓글 수: 1
José-Luis
José-Luis 2014년 6월 13일
What do you want to do about the negative values in your plot? Just not show them?

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

답변 (2개)

dpb
dpb 2014년 6월 13일
Sure,
plot(x,abs(y))
I'm guessing that's not what you mean, precisely, however. If you mean instead to simply display abs() of tick labels even if the y-limits include some negatives, then try
set(gca,'yticklabel',num2str(abs(get(gca,'ytick').')))
  댓글 수: 2
Samuel
Samuel 2014년 6월 13일
Thank you very much. That's exactly what I meant. Maybe I should have said that I don't wanna change any plot-data ;)
dpb
dpb 2014년 6월 13일
Then please accept an answer so others won't needlessly try...

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


Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 13일
yl=get(gca,'ylim')
ylim([0 max(yl)])

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by