Calling sequence and line styles |
![]() |
Note: The strings in the cursor and auxiliary commands are case sensitive. All other plt string arguments are case insensitive.
If no arguments are specified, plt will display the workspace plotter. For plt to plot data it must have at least one argument specifying the y-values to be displayed. More often you will call plt with two arguments:
plt(x,y);
This plots the data in vector x along the horizontal axis and the data in vector y along the vertical axis. x and y may be row or column vectors. Plt will transpose one of the arguments if needed to line things up, so x could be a row vector while y was a column vector. x and y must be the same length however. If not you will get an error message saying that the vectors must be the same length.
If y is a real vector, plt(y) is equivalent to plt(1:length(y),y).
To plot more than one trace include the x and y vectors for each trace in the argument list. For example plt(x1,y1,x2,y2,x3,y3) plots three traces. Quite often several traces share the same x vector. In this case we can simply repeat the x vector in the argument list, as in plt(x,y1,x,y2,x,y3) or a shorthand way of writing that is plt(x,[y1;y2;y3]). That would work only if the y1,y2,y3 were row vectors. If they were column vectors you would need to write plt(x,[y1 y2 y3]).
Plt returns a column vector of handles to the lines that it creates. For instance the above command returns a 3x1 vector. The first element of that vector is the line handle associated with the y1 trace. Most often when you type the plt command at the command prompt you don't need to save plt's return value. However when plt is called from a program the line handles are often required to allow further manipulations of the plot.
If x and y are both matrices of the same size, plt(x,y) will create one trace per column.
None of this so far should come as a surprise since it is identical to Matlab's plot command.
Also like plot, if y is a complex vector, plt(y) is equivalent to plt(real(y),imag(y)). Unlike plot however, complex arguments are treated this way no matter where they appear in the argument list. For instance if a and b are both complex, plt(a,b) is equivalent to plt(real(a),imag(a),real(b),imag(b)). This doesn't work with plot for some reason.
Also like the plot command you can include any line property in the argument list. For example:
plt(x,y,'LineWidth',2) is equivalent to set(plt(x,y),'LineWidth',2)
One difference in the behaviors of plt and plot is that with plot these line properties must appear after all the data vectors in the argument list. (plot gives an error otherwise). With plt the line properties may occur in the middle of the argument list. In that case, the line property is applied only to the lines defined earlier in the argument list. For example:
plt(x,[y1;y2],'Marker','Diamond',x,[y3;y4]);
only sets the Marker property for the first two traces. An equivalent to the
above is:
a=plt(x,[y1;y2;y3;y4]); set(a(1:2),'Marker','Diamond');
By using cell arrays, you can set properties differently on each trace. For example:
plt(x,[y1;y2;y3;y4],'LineWidth',{2 2 4 2});
This would set the LineWidth of the trace associated with y3 to 4 and the other three traces to 2. A column ({2;2;4;2}) would have worked equally as well. The number of elements in the row or column vector must identical to the number of traces defined so far in the argument list. (so as above, traces defined after the LineWidth parameter will just be assigned to the default LineWidth. Two more examples are:
plt(x,[y1;y2;y3;y4],'LineStyle',{'-' ':' '-.' 'none'});
plt(x,[y1;y2;y3],'Marker',{'square','none ','+'});
Note that this method of assigned properties applies to any line property. In the two particular line properties used above, you could have replaced 'LineStyle' with 'Styles' and 'Marker' with 'Markers' and the results would be the same. Styles and Markers are not really line properties, however plt allows you to use those alternate forms to allow some additional flexibility in how you write the parameter that follows it. (For example a character array may be used in place of the cell array.) The details of the additional flexibility provided by using these two alternate parameters are described in the Trace properties section below.
The special plot types vertical bars, error bars, and vector fields (arrows) are plotted with the help of auxiliary functions vbar, ebar and quiv. The use of these functions is described in the Auxiliary .m files section.
Figure application data:
After a call to plt, the following information is available from the figure application data:
| getappdata(gcf,'axis') | Returns a vector of handles of the axes containing the plotted data. The first handle in the vector is the left hand main plot. This is followed by the subplot axes (if any) from the bottom up. Finally, the last element of the vector will be the handle of the main plot right hand axis (if any). |
| getappdata(gcf,'cid') | Returns the cursor IDs for each axis, starting with the main (lower) axis and working upwards to include all the subplot axes. |
| getappdata(gcf,'Lhandles') | Returns a list of all handles of all data traces created by plt. Note that this is identical to the plt return value. |
| getappdata(ax,'Lhandles') | Each axis (except the right hand axis) also has a 'Lhandles' application data value. This contains a list of all lines contained in that axis. For the main (lower) plot, this list contains the traces on either the left or right hand axis. Since each subplot axis contains only one line, the Lhandles application data will be a scalar. |
| plt help | Displays the plt help file. You could also use the functional form of this command: plt('help'). To get a much shorter help system display type help plt. |
| plt version | Returns the plt version. Same as: plt('version') |
| plt save | Opens a dialog box allowing you to select a .plt figure file that can be opened later using the plt open item in the file menu. If you want to avoid the file dialog box add the file name as a 3rd argument (i.e. plt save filename). The use of these plt figure files are described in more detail in the Menu box section. |
| plt open | Opens a dialog box allowing you to select a .plt figure file that was saved using the plt save item in the file menu. If you want to avoid the file dialog box add the file name as a 3rd argument (i.e. plt open filename). |
|
plt close plt closefigs |
If a programming error causes plt to crash, you may find it difficult to close the plt figure windows (because they use the close request function). This command solves the problem by closing all currently open plt figure windows. Figure windows not created by plt are not closed. (The shorter and longer forms are equivalent and of course you may also use the functional forms.) |