y-axis only absolute values

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 Kommentar

José-Luis
José-Luis am 13 Jun. 2014
What do you want to do about the negative values in your plot? Just not show them?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

dpb
dpb am 13 Jun. 2014

4 Stimmen

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 Kommentare

Samuel
Samuel am 13 Jun. 2014
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 am 13 Jun. 2014
Then please accept an answer so others won't needlessly try...

Melden Sie sich an, um zu kommentieren.

Azzi Abdelmalek
Azzi Abdelmalek am 13 Jun. 2014

0 Stimmen

yl=get(gca,'ylim')
ylim([0 max(yl)])

Gefragt:

am 13 Jun. 2014

Kommentiert:

dpb
am 13 Jun. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by