stuck on graph format! please help

2 次查看(过去 30 天)
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')??

回答(1 个)

Walter Roberson
Walter Roberson 2018-2-4
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-');

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by