Matlab - axes properties

187 views Asked by At

How to make x-axis and y-axis cross at origin and label the axes in both sides, i.e 'xlabel' in +ve x-axis and 'xlabel' in -ve x-axis and similarly for 'ylabel'.

1

There are 1 answers

0
Benoit_11 On BEST ANSWER

You can use the function drawaxis taken here to position the x- and y- axis. Then you can add text annotations as labels. The function does have a few limitations but that's very easy to use.

clear
clc
close all

x = -10:10;
y = rand(size(x))-.5;
plot(x,y)

%// Here the axes cross at(0,0)
drawaxis(gca, 'x', 0,'y',0)

text(5,-.05,'+ axis','HorizontalAlignment','center')
text(-5,-.05,'- axis','HorizontalAlignment','center')

Output:

enter image description here