MATLAB Answers

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

6 views (last 30 days)
daniel on 8 Dec 2014
Commented: daniel on 8 Dec 2014
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.


Sign in to comment.

Accepted Answer

Mohammad Abouali
Mohammad Abouali on 8 Dec 2014
Well, if you change
it would generate a line.
However, if you want to change your axis limit that is not a proper approach
xlim([minXAxisValue maxXAsixValue])
ylim([minYAxisValue maxYAsixValue])


daniel on 8 Dec 2014
beautiful, so simple.. I understand perfectly, thanks!
daniel on 8 Dec 2014
Mohammad, suppose I want to plot a line across y = -15.
will produce the line but is there a cleaner way of doing this?

Sign in to comment.

More Answers (0)

Translated by