5.4.1 Basic 2D Plotting

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

Figure 5.1: First example of plotting
\begin{figure}\begin{center}
\fbox{\begin{picture}(300.00,212.00)
%%%%%%%%%%%%%%...
...0}
\end{picture}}\end{center}<tex2html_endfile> ...

The generic 2D multiple plot is

plot2di(x,y,<options>)

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')

Figure 5.2: Different 2D plotting
\begin{figure}\begin{center}
%%If you prefer cm use the followin two lines
\f...
...es/nouv1.epsf hscale=100.0 vscale=100.0}
\end{picture}}\end{center} \end{figure}

//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]);

Figure 5.4: Box, captions and tics
\begin{figure}\begin{center}
%%If you prefer cm use the followin two lines
\f...
...es/nouv3.epsf hscale=100.0 vscale=100.0}
\end{picture}}\end{center} \end{figure}

For different plots the simple commands without any argument show a demo (e.g plot2d3() ).