Why can't I plot a simple line???

2 次查看(过去 30 天)
I am trying to change the limits of my axis, and just draw a line through x = 0. But for some reason if I only specify a solid line in my LineStyle, matlab wont plot anything, if I choose anything else it works fine i.e *,o,>,<.... I will just do a simple example to illustrate my point.
>> figure
>> hold on
>> grid on
>> set(gca,'LineWidth',1)
>> axis([-10,10,0,30]);
>> plot(0,0:1:30,'r-') %% this produces nothing
>> plot(0,0:1:30,'r-*')%% this and everything else does..
>> plot(0,0:1:30,'r-o')
>> plot(0,0:1:30,'r->')
>> plot(0,0:1:30,'r-<')
Any idea why? Any help will be appreciated.
-D

采纳的回答

Mohammad Abouali
Mohammad Abouali 2014-12-8
Well, if you change
plot(0,0:1:30,'r-')
to
plot(zeros(1,31),0:1:30,'r-')
it would generate a line.
However, if you want to change your axis limit that is not a proper approach
Use
xlim([minXAxisValue maxXAsixValue])
ylim([minYAxisValue maxYAsixValue])
  3 个评论
daniel
daniel 2014-12-8
Mohammad, suppose I want to plot a line across y = -15.
plot(0:1:100,-15.*ones(101,1),'r-')
will produce the line but is there a cleaner way of doing this?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by