to quickly customize the lines appearance in a plot
The LineSpec is an optional argument that can be used inside a plot command to customize each new line aspect. It has to be given as a concatenated string containing information about color, line style or markers. It is very useful to quickly specify such basic line properties.
To specify a red longdash-dot with diamond marker, the string can be ‘r-.diam’. As you can see, a full complete spelling of each property value is not required but the string, which is a concatenation (in any order) of these three types of properties , must remain unambiguous. Furthermore, the string specification is not case sensitive.
Here is a complete list of the LineSpec types you can specify (using plot).
LineStyle: | a string defining the line style. This property is linked to the object’s line_style property (see polyline_properties). Specifier Line Style - Solid line (default) – Dashed line : Dotted line -. Dash-dotted line |
---|
:
x=1:0.1:10; // Init.
`plot`_(x,`sin`_(x),'r.->') // plots a dash-dotted line with a right-pointing triangle centered on each points.
`clf`_();
// If you specify a marker wihtout a line style, only the marker is drawn
`plot`_(x,`sin`_(x),'d') // plots a dash-dotted line with a right-pointing triangle centered on each points.
x=1:10; // Init.
// combinations' order does not matter
`plot`_(x,x.*x,'*cya--')
//multiple plots with different LineSpecs
`clf`_();
t=0:%pi/20:2*%pi;
`plot`_(t,`sin`_(t),'ro-.',t,`cos`_(t),'cya+',t,`abs`_(`sin`_(t)),'--mo')