next up previous contents index
Next: 5.4.2 Captions and Presentation Up: 5.4 2D Plotting Previous: 5.4 2D Plotting

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)
% if you wan...
...es/d7-1.eps hscale=100.00 vscale=100.00}
\end{picture}}\end{center}
\end{figure}

The generic 2D multiple plot is

plot2di(str,x,y,[style,strf,leg,rect,nax])

t=(1:0.1:8)';xset("font",2,3);
xsetech([0.,0.,0.5,0.5],[-1,1,-1,1]);
plot2d([t t],[1.5+0.2*sin(t) 2+cos(t)]);
xtitle('Plot2d');
titlepage('Piecewise linear');
//
xsetech([0.5,0.,0.5,0.5],[-1,1,-1,1]);
plot2d1('oll',t,[1.5+0.2*sin(t) 2+cos(t)]);
xtitle('Plot2d1');
titlepage('Logarithmic scale(s)');
//
xsetech([0.,0.5,0.5,0.5],[-1,1,-1,1]);
plot2d2('onn',t,[1.5+0.2*sin(t) 2+cos(t)]);
xtitle('Plot2d2');
titlepage('Piecewise constant');
//
xsetech([0.5,0.5,0.5,0.5],[-1,1,-1,1]);
plot2d3('onn',t,[1.5+0.2*sin(t) 2+cos(t)]);
xtitle('Plot2d3')
titlepage('Vertical bar plot')
xset('default')

Figdirfigures/

  
Figure 5.2: Different 2D plotting
\begin{figure}
\begin{center}
\fbox{\begin{picture}
(300.0,212.0)
\special{ps...
...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=-%pi:0.3:%pi;
y1=sin(x);y2=cos(x);y3=x;
X=[x;x;x]; Y=[y1;y2;y3];
plot2d1("gnn",X',Y',[1 2 3]',"111","caption1@caption2@caption3",...
[-3,-3,3,2],[2,20,5,5]);

Figdirfigures/

  
Figure 5.4: Box, captions and tics
\begin{figure}
\begin{center}
\fbox{\begin{picture}
(300.0,212.0)
\special{ps...
...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() ).


next up previous contents index
Next: 5.4.2 Captions and Presentation Up: 5.4 2D Plotting Previous: 5.4 2D Plotting
Scilab Group