stuck on graph format! please help

4 views (last 30 days)
PetronasAMG
PetronasAMG on 4 Feb 2018
Answered: Walter Roberson on 4 Feb 2018
so this is what I have..
but i need to make my graph look like this
as far as my coding,
grid on;
axis('equal')
posdegreeline = refline(tand(angle),0);
negdegreeline = refline(-tand(angle),0);
posdegreeline.Color = 'r';
negdegreeline.Color = 'r';
o1 = gca;
o1.XAxisLocation = 'origin';
o1.YAxisLocation = 'origin';
hold off;
my angle is 45 degrees but red lines suppose to end below the origin. I can't figure out why also is there a way to adjust scale even though i used axis('equal')??

Answers (1)

Walter Roberson
Walter Roberson on 4 Feb 2018
In order to do this using refline(), you will need to create a second axes in which the YLim upper value is the same as the YLim upper value in the original axes, but the YLim lower value is set to 0; and in the second axes, the XLim will need to be [-4 4]. Now use refline() in that second axes and record the handles. Now take the resulting line objects and set their Parent property to be the first axes (and then delete the second axes.)
Personally, I think it would be much easier just to do a line() or plot()
YL = ylim();
Ymax = YL(2);
plot([-Ymax 0 Ymax], [Ymax, 0, yMax], 'r-');

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!