# suggest me how to plot 45 degree line in MATLAB?

47 views (last 30 days)
SAGAR PATEL on 22 Feb 2019
Edited: John D'Errico on 11 Jan 2020
how can I plot a line with 45 degree angle in the graph as reference line????
when I use the code "refline" the line I got different angle line and I want 45 degree angle line from the centre of both axes so please suggest me how can I get.
##### 2 CommentsShow 1 older commentHide 1 older comment
SAGAR PATEL on 23 Feb 2019
I mean, I want 45 degree reference line. can I get that by give the same axis limit????

Jan on 22 Feb 2019
I guess, that you do get a 45 deg angle, but that the different scaling of X and Y axes let it look in another angle. See:
axis equal
to use the same scaling for both directions.
##### 2 CommentsShow 1 older commentHide 1 older comment
Stephen23 on 23 Feb 2019
Edited: Stephen23 on 23 Feb 2019
"so I have to give same axis limit is it right"
That depends...
To a get a 45 degree line in the data space, the axis limits are irrelevant.
If you are trying to get a 45 degree line on the screen (rather than in the data space and without using equal axis) you would need to get the displayed size of the axes and your screen resolution and figure it out the required data from that. Then the limits might be useful.

Pankaj Dey on 11 Jan 2020
hline = refline([1 0]);
hline.Color = 'k';
hline.LineStyle = ':';
hline.HandleVisibility = 'off';
Source: https://fanwangecon.github.io/M4Econ/graph/main/fs_lines.html
##### 2 CommentsShow 1 older commentHide 1 older comment
Pankaj Dey on 11 Jan 2020
Thank you for your clarification !