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

조회 수: 2 (최근 30일)
daniel
daniel 2014년 12월 8일
댓글: daniel 2014년 12월 8일
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
Mohammad Abouali
Mohammad Abouali 2014년 12월 8일
You are welcome
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