The simplest 2D plot is plot(x,y) or plot(y): this is the plot of y as function of x where x and y are 2 vectors; if x is missing, it is replaced by the vector (1,size(y,'*'))). If y is a matrix, its rows are plotted. There are optional arguments.
A first example is given by the following commands and one of the results is represented on figure 5.1:
t=(0:0.05:1)'; ct=cos(2*%pi*t); // plot the cosine plot(t,ct); // xset() opens the toggle panel and // some parameters can be changed with mouse clicks // given by commands for the demo here xset("font",5,4);xset("thickness",3); // plot with captions for the axis and a title for the plot // if a caption is empty the argument ' ' is needed plot(t,ct,'Time','Cosine','Simple Plot'); // click on a color of the xset toggle panel and do the previous plot again // to get the title in the chosen color
The generic 2D multiple plot is
plot2di(x,y,<options>)
plot2d
: i=missing,2,3,4.
For the different values of i we have:
i=missing : piecewise linear/logarithmic plotting
i=2 : piecewise constant drawing style
i=3 : vertical bars
i=4 : arrows style (e.g. ode in a phase space)
t=(1:0.1:8)';xset("font",2,3); subplot(2,2,1) plot2d([t t],[1.5+0.2*sin(t) 2+cos(t)]); xtitle('Plot2d-Piecewise linear'); // subplot(2,2,2) plot2d(t,[1.5+0.2*sin(t) 2+cos(t)],logflag='ll'); xtitle('Plot2d1-Logarithmic scales'); // subplot(2,2,3) plot2d2(t,[1.5+0.2*sin(t) 2+cos(t)]); xtitle('Plot2d2-Piecewise constant'); // subplot(2,2,4) plot2d3(t,[1.5+0.2*sin(t) 2+cos(t)]); xtitle('Plot2d3-Vertical bar plot')
For a single curve the vector can be row or column:
plot2d(t',cos(t)') plot2d(t,cos(t)) are equivalent.
xmax=5.;x=0:0.1:xmax; u=[-0.8+sin(x);-0.6+sin(x);-0.4+sin(x);-0.2+sin(x);sin(x)]; u=[u;0.2+sin(x);0.4+sin(x);0.6+sin(x);0.8+sin(x)]'; //start trying the symbols (negative values for the style) plot2d(x,u,style=[-9,-8,-7,-6,-5,-4,-3,-2,-1,0]) x=0:0.2:xmax; v=[1.4+sin(x);1.8+sin(x)]'; xset("mark size",5); plot2d(x,v,style=[-7,-8]) xset('default');
requirements | ranges | ranges | ranges |
of a previous | given by | computed from | |
actual | plot | rect arg | x and y |
requested | |||
one | 0 | 1 | 2 |
Computed | |||
for isometric | 3 | 4 | |
view | |||
Enlarged | |||
For pretty | 5 | 6 | |
axes | |||
Previous and | |||
current | 7 | 8 | |
plots merged |
//captions for identifying the curves //controlling the boundaries of the plot and the tics on axes x=-5:0.1:5; y1=sin(x);y2=cos(x); X=[x;x]; Y=[y1;y2]; plot2d(X',Y',style=[-1 -3]',leg="caption1@caption2",... rect=[-5,-1,5,1],nax=[2,10,5,5]);
For different plots the simple commands without any argument show a demo (e.g plot2d3() ).