Draw a set of negative data in the "positive" Y axis

I have a dataset that I want to build in MATLAB, the problem is that this dataset is negative. I want to plot it along the Y axis as if it were positive, so the graph remains in the first quadrant, and I also want the values ​​to display as negative.

I obviously tried:

plot(x,-y);

But this does not work, because it displays the first quadrant, but the values ​​are converted to positive.

Any help on how to do this? I was looking for documentation and forums, and I could not find it.

+4
source share
2 answers

Perhaps you want to change the direction in which values ​​grow on the axis y?

x = -rand(100,1); %// some negative data
figure;
ah = axes;
plot(1:100, x);
%// reverse the direction in which values on y-axis increase
set(ah,'ydir','reverse')

. , XDir, YDir ZDir.

+2

y. :

x = 1:10;
y = -1:-1:-10;

plot(x,abs(y))
ax = gca;
ax.YTick = abs(y);
ax.YTickLabel = num2cell(y);
+1

Source: https://habr.com/ru/post/1617571/


All Articles