Whats wrong with this 45 degree line on the plot?
Show older comments
Hey all, I wanted to have a 45-degree line on my plot in order to have a background for comparing with the trend line of forecasted. I used this code in order to make this 45 degree line:
class1 = scatter(X,Y,12,'k','filled');
plot(1:max(X),'k'); %45 degree line (black)
plot(1:max(X),pp(1)*(1:max(X))+pp(2)); %trend line
In some of my data, everything is okay but in others, I achieve this figure:

I don't know why this happens. I want to have a black line in 45 degrees and trend line corresponding to it just like this picture below:

(Black is the 45-degree line and red is trend line)
Could anyone help me?
Thanks
Accepted Answer
More Answers (1)
Image Analyst
on 5 Apr 2020
After you plot, call
axis equal
as long as both axes have the same units, like both are mm, and NOT like x is the array index and y is in mm.
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
