- Ajuda do Scilab
- Biblioteca de Gráficos
- 2d_plot
- champ
- champ1
- champ_properties
- comet
- contour2d
- contour2di
- contour2dm
- contourf
- cutaxes
- errbar
- fchamp
- fec
- fec properties
- fgrayplot
- fplot2d
- grayplot
- grayplot_properties
- graypolarplot
- histplot
- LineSpec
- loglog
- Matplot
- Matplot1
- Matplot properties
- paramfplot2d
- plot
- plot2d
- plot2d2
- plot2d3
- plot2d4
- plotimplicit
- polarplot
- scatter
- semilogx
- semilogy
- Sfgrayplot
- Sgrayplot
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
plot2d
2D plot
Syntax
plot2d() // example plot2d(y) plot2d(x, y) plot2d(logflag, x, y) plot2d(.., y, style) plot2d(.., y, style, strf) plot2d(.., y, style, strf, leg) plot2d(.., y, style, strf, leg, rect) plot2d(.., y, style, strf, leg, rect, nax) plot2d(.., y, key1=value1, key2=value2, ..)
Arguments
- x
- a real matrix or vector of abscissae. If omitted, abscissae are assumed to
be
1:n
for all curves, wheren
is the number of points in curves, as given byy
. - y
- real matrix or vector: Ordinates
- key1=value1, key2=value2, ...
The following options
logflag
,style
,strf
,leg
,rect
,nax
,frameflag
, andaxesflag
described below can either be listed in the right order as listed in the synopses, or provided in any order aftery
as named arguments, for instance like inplot(y, frameflag=3, leg="Curve 1@Curve 2")
.- logflag
Sets the linear or logarithmic scale for both X and Y axes. Possible values are
"nn"
,"nl"
,"ln"
or"ll"
."n"
stands for normal scale ;"l"
stands for logarithmic. The first letter set the X axis. The second one sets the Y axis.- style
Sets the respective line or mark styles of the curves. It is a vector of decimal integers with one element per curve:
- if
style(i)
is strictly positive, the curve is drawn as plain line andstyle(i)
defines the index of the color used to draw the curve (see getcolor). - if
style(i)
is negative or zero, the given curve points are drawn using marks. Thenabs(style(i))
is the mark's id.
Note that all curves properties -- like also their color, thickness, marks colors, etc -- can be set through their handles (see polyline_properties).
- if
- strf
- 3-character-long string
"abc"
specifying all together if legends must be displayed, and the values offrameflag
andaxesflag
. By default,strf= "081"
. "a", "b" and "c" are:a : controls the display of captions: a=0 : no caption. a=1 : captions given by the optional argument leg
are displayed.b : frameflag
integer code in [0,9], controlling the computation the actual coordinate ranges, as described below.c : axesflag
integer code in [0:5 9], controlling the display and position of X and Y axes, as described below. - leg
Single string
"leg1@leg2@...."
setting the legends leg1, leg2, etc for the respective curves #1, #2, etc. The default is" "
. The block of legends is drawn on the bottom, below the x-axis.After plotting, the handle of the block of legends can be retrieved with
gca().children(2)
. captions, legend or legends can also be used instead ofleg
.- rect
Vector of decimal numbers
[xmin, ymin, xmax, ymax]
setting the minimal bounds requested for the plot.[xmin, xmax]
is the X-axis range, and[ymin, ymax]
is the Y-axis one.This argument works with the
frameflag
option to specify how the actual axes boundaries are computed. If theframeflag
option is not given, it is supposed to beframeflag=7
.The axes boundaries can also be customized through the
gca().data_bounds
property of the axes (see axes_properties).- nax
Vector of decimal integers
[nx,Nx,ny,Ny]
specifying the numbers Nx and Ny of major ticks, and the numbers nx and ny of minor ticks between 2 majors, for both respective axes. To use autoticking on an axis, set Nx=-1 or Ny=-1.If the
axesflag
option is not specified, usingnax
sets and usesaxesflag=9
.- frameflag
controls the computation of the actual coordinate ranges from the minimal requested values. The associated value should be an integer ranging from 0 to 8.
frameflag axes bounds other actions 0 unchanged 1 from rect 2 from input x,y 3 from rect isometric axes 4 from input x,y isometric axes 5 from rect pretty axes 6 from input x,y pretty axes 7 from rect all replot with new scales 8 from input x,y all replot with new scales 9 from input x,y Pretty axes. All replot with new scales The setting of axes boundaries can also be customized through the
gca().data_bounds
,gca().tight_limits
,gca().data_bounds
, andgca().isoview
properties (see axes_properties).- axesflag
integer code in [0:5 9], controlling the display and position of X and Y axes.
The axes aspect can also be customized directly through the
gca().box
,gca().axes_visible
,gca().x_location
, andgca().y_location
, properties (see axes_properties).axesFlag .box .axes_visible axes position comments 0 "off" ["off" "off"] Naked plot 1 "on" ["on" "on"] 2 "on" ["off" "off"] Naked box 3 "off" ["on" "on"] y_location="right" 4 "off" ["on" "on"] crossed @ middle 5 "on" ["on" "on"] crossed @ middle 9 "off" ["on" "on"] (default setting)
Description
plot2d
plots a set of 2D curves. Piecewise linear interpolation
is done between the given curve points.
Any point with y(i)=Nan
is masked: no mark and no segment to its
neighboors are displayed.
For any point with y(i)=±Inf
, a vertical segment starting
from each of its both neighboors is drawn in the ± direction, up to the current ceil
or down to the current floor of the axes.
By default, successive calls to plot2d() overplots new curves over existing ones.
Autoclearing for each new plot can be set using gca().auto_clear="on"
.
Please see axes properties.
clf
can also be used to manually clear
the whole figure.
If you are familiar with Matlab plot
syntax, you should use
plot instead.
If x
and y
are vectors,
plot2d(x,y,…) plots vector y
versus
vector x
. x
and y
vectors should have the same number of entries.
If x
is a vector and y
a
matrix plot2d(x,y,…) plots each columns of
y
versus vector x
. The
number of rows of y
must be equal to the number of
x
entries.
If x
and y
are matrices,
plot2d(x,y,…) plots each columns of y
versus corresponding column of x
.
x
and y
must then have the same sizes.
If y
is a vector, plot2d(y,…)
plots vector y
versus vector
1:size(y,'*')
.
If y
is a matrix, plot2d(y,…)
plots each columns of y
versus vector
1:size(y,1)
.
Enter the command plot2d()
to see a demo.
Other high level plot2d functions 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 vertical arrows.
Examples
// x initialisation x=[0:0.1:2*%pi]'; //simple plot plot2d(sin(x));
// multiple plot giving the dimensions of the frame clf(); x=[0:0.1:2*%pi]'; plot2d(x,[sin(x) sin(2*x) sin(3*x)],rect=[0,0,6,0.5]);
//multiple plot with captions and given tics + style clf(); x=[0:0.1:2*%pi]'; 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]);
// auto scaling with previous plots + style clf(); x=[0:0.1:2*%pi]'; plot2d(x,sin(x),-1); plot2d(x,2*sin(x),12); plot2d(2*x,cos(x),3);
// axis on the right clf(); x=[0:0.1:2*%pi]'; plot2d(x,sin(x),leg="sin(x)"); a=gca(); // Handle on axes entity a.y_location ="right";
// axis centered at (0,0) clf(); x=[0:0.1:2*%pi]'; plot2d(x-4,sin(x),1,leg="sin(x)"); a=gca(); // Handle on axes entity a.x_location = "origin"; a.y_location = "origin"; // Some operations on entities created by plot2d ... isoview a=gca(); a.children // list the children of the axes. // There are a compound made of two polylines and a legend poly1= a.children(1).children(1); //store polyline handle into poly1 poly1.foreground = 4; // another way to change the style... poly1.thickness = 3; // ...and the thickness of a curve. poly1.clip_state='off'; // clipping control leg = a.children(2); // store legend handle into leg leg.font_style = 9; leg.line_mode = "on"; isoview off
See also
- plot — Esboço 2d
- .polyline_style — description of the Polyline entity properties
- plot2d2 — esboço 2d (funções de degraus)
- plot2d3 — esboço 2d (barras veticais)
- plot2d4 — esboço 2d (setas)
- polarplot — Esboço de coordenadas polares
- gca — Retorna o manipulador da entidade Axes corrente close — Closes graphic figures, progression or wait bars, the help browser, xcos, the variables browser or editor.
- axes_properties — descrição das propriedades de entidades Axes (de eixos)
- clf — Clears and resets a figure or a frame uicontrol
Report an issue | ||
<< plot | 2d_plot | plot2d2 >> |