How to graph a number line with an interval or ray shown on it?
Show older comments
In Wolfram Mathematica there is a function called NumberLinePlot that plots data on nuber line like an interval (closed or open) or rays. I am wonder if there is such a plot function in Matlab? (see example from Wolfram Mathematica bellow in the attached picture). What would be the code to create such a graph in Matlab.

Answers (1)
Nothing like that exists in MATLAB handle graphics and nothing can be drawn in MATLAB other than into a figure axes, so it's unlikely you'll find this of any real value, but one can klunk something sorta' similar together excepting it will still be tied to the figure...
hAx=axes;
pos=hAx.Position;
pos(4)=0.05;
hAx.Position=pos;
hAx.YAxis.Visible='off';
hAx.XAxis.TickLength=0* hAx.XAxis.TickLength;
box off
xlim([-1.1 0.15])
hAx.XAxis.TickLabelFormat='%0.1f';
hA=annotation('textarrow',[0.5 0.9],0.15*[1 1]);
%hL=plot([0 0],[nan nan],'k-'); % this didn't work
%hLg=legend(hL,'X > -1/2','Location','eastoutside');
Other stuff would have to be added with text or other annotation.
The end result is you can draw something that looks similar, but not sure it would be of any use having done so...
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!