1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
plot2d Scilab Group Scilab Function plot2d
NAME
plot2d - 2D plot
CALLING SEQUENCE
plot2d([x],y)
plot2d([x],y,<opt_args>)
plot2d([logflag],x,y,[style,strf,leg,rect,nax])
PARAMETERS
x,y : two matrices or vectors.
- If y is a vector, x must be a vector with the same size. If
x is not given, it is supposed to be the vector 1:<size of
y>.
- If y is a matrix, x can be:
+ a vector with size equal to the row dimension of y
(each column of y is plotted with respect to x)
+ a matrix with the same dimensions as y (each column of
y is plotted with respect to the corresponding column of
x)
+ If x is not given, it is supposed to be the vector
1:<row dimension of y>
<opt_args> : This represents a sequence of statements key1=value1,
key2=value2,... where key1, key2,... can be one of the
following:
style : sets the style for each curve, see below for
value.
leg : sets the curves captions. If this key is given and
strf is not given then x character of strf is
supposed to be 1. See below for value.
rect : sets the bounds of the plot. If this key is given
and neither frameflag nor strf is given then the y
character of strf is supposed to be 7. See below for
value.
nax : sets the grids definition. If this key is given
and neither axesflag nor strf is given then the z
character of strf is supposed to be 1. See below for
value.
logflag : sets the graduation type (linear or logarithmic)
along the axes. See below for value.
frameflag : specifies how the frame of the plot is computed.
The value is an integer ranging from 0 to 8. It
corresponds to the y character of strf. See below.
axesflags : specifies what kind of axes are drawn around the
plot. The value is an integer ranging from 0 to 5. It
corresponds to the z character of strf. See below.
style : is a real row vector of size nc. The style to use for curve
i is defined by style(i). The default style is 1:nc (1 for
the first curve, 2 for the second, etc.).
- if style(i) is negative or zero, the curve is plotted
using the mark with id abs(style(i)); use xset() to set
the mark id and xget('mark') to get the current mark id.
- if style(i) is strictly positive, a plain line with color
id style(i) or a dashed line with dash id style(i) is
used; use xset() to see the color ids.
- When only one curve is drawn, style can be the row vector
of size 2 [sty,pos] where sty is used to specify the style
and pos is an integer ranging from 1 to 6 which specifies a
position to use for the caption. This can be useful when a
user wants to draw multiple curves on a plot by calling
the function plot2d several times and wants to give a
caption for each curve.
strf : is a string of length 3 "xyz".
x : controls the display of captions.
x=0 : no caption.
x=1 : captions are displayed. They are given by the
optional argument leg.
y : controls the computation of the actual coordinate
ranges from the minimal requested values. Actual ranges
can be larger than minimal requirements.
| requirements|ranges |ranges |ranges |
| |of a previous|given by |computed from|
|actual |plot |rect arg |x and y |
|-------------- |------------ |--------- |-------------|
|requested | | | |
|one | y=0 | y=1 | y=2 |
|-------------- |------------ |--------- |-------------|
|Computed | | | |
|for isometric | | y=3 | y=4 |
|view | | | |
|-------------- |------------ |--------- |-------------|
|Enlarged | | | |
|For pretty | | y=5 | y=6 |
|axes | | | |
|-------------- |------------ |--------- |-------------|
|Previous and | | | |
|current | | y=7 | y=8 |
|plots merged | | | |
|-------------- |------------ |--------- |-------------|
| | | | |
z : controls the display of information on the frame around
the plot. If axes are requested, the number of tics can be
specified by the nax optional argument.
z=0 : nothing is drawn around the plot.
z=1 : axes are drawn, the y=axis is displayed on the
left.
z=2 : the plot is surrounded by a box without tics.
z=3 : axes are drawn, the y=axis is displayed on the
right.
z=4 : axes are drawn centred in the middle of the frame
box.
z=5 : axes are drawn so as to cross at point (0,0). If
point (0,0) does not lie inside the frame, axes will
not appear on the graph.
leg : a string. It is used when the first character x of
argument strf is 1. leg has the form "leg1@leg2@...." where
leg1, leg2, etc. are respectively the captions of the first
curve, of the second curve, etc. The default is " ".
rect : This argument is used when the second character y of
argument strf is 1, 3 or 5. It is a row vector of size 4 and
gives the dimension of the frame: rect=[xmin,ymin,xmax,ymax].
nax : This argument is used when the third character z of
argument strf is 1. It is a row vector with four entries
[nx,Nx,ny,Ny] where nx (ny) is the number of subgraduations on
the x (y) axis and Nx (Ny) is the number of graduations on the
x (y) axis.
logflag : a string formed by to characters h (for horizontal axis)
and v (for vertical axis) each of these characters can take
the values "n" or "l". "l" stands for logarithmic graduation
and "n" for normal graduation. For example "ll"stands for a
log-log plot. Default value is "nn".
DESCRIPTION
plot2d plots a set of 2D curves. Piecewise linear plotting is used. By
default, successive plots are superposed. To clear the previous plot,
use xbasc(). See the meaning of the parameters above for a complete
description. Enter the command plot2d() to see a demo. Other high level
plot2d function exist:
plot2d2 : same as plot2d but the curve is supposed to be piecewise
constant.
plot2d3 : same as plot2d but the curve is plotted with vertical bars.
plot2d4 : same as plot2d but the curve is plotted with arrows.
EXAMPLE
//simple plot
x=[0:0.1:2*%pi]';
plot2d(sin(x))
xbasc()
plot2d(x,sin(x))
//multiple plot
xbasc()
plot2d(x,[sin(x) sin(2*x) sin(3*x)])
// multiple plot giving the dimensions of the frame
// old syntax and new syntax
xbasc()
plot2d(x,[sin(x) sin(2*x) sin(3*x)],1:3,"011"," ",[0,0,6,0.5])
xbasc()
plot2d(x,[sin(x) sin(2*x) sin(3*x)],rect=[0,0,6,0.5])
//multiple plot with captions and given tics
// old syntax and new syntax
xbasc()
plot2d(x,[sin(x) sin(2*x) sin(3*x)],..
[1,2,3],"111","L1@L2@L3",[0,-2,2*%pi,2],[2,10,2,10])
xbasc()
plot2d(x,[sin(x) sin(2*x) sin(3*x)],..
[1,2,3],leg="L1@L2@L3",nax=[2,10,2,10],rect=[0,-2,2*%pi,2])
// isoview
xbasc()
plot2d(x,sin(x),1,"041")
// scale
xbasc()
plot2d(x,sin(x),1,"061")
// auto scaling with previous plots
xbasc()
plot2d(x,sin(x),1)
plot2d(x,2*sin(x),2)
plot2d(2*x,cos(x),3)
// axis on the right
xbasc()
plot2d(x,sin(x),1,"183","sin(x)")
// centered axis
xbasc()
plot2d(x,sin(x),1,"184","sin(x)")
// axis centered at (0,0)
xbasc()
plot2d(x-4,sin(x),1,"185","sin(x)")
SEE ALSO
plot2d1, plot2d2, plot2d3, plot2d4, xbasc, xset
AUTHOR
J.Ph.C.
|