plot::Pointlist
-- graphical
primitive for a list of pointsplot::Pointlist
(p1, p2...)
represents a
plot of either two- or three-dimensional points. Several drawing
options exist such as drawing a line from point to point, or drawing a
horizontal or vertical line from the axes to each point.
plot::Pointlist(p1, p2... <, option1,
option2...>)
p1, p2 |
- | plot points, i.e., objects that can be converted into
the domain plot::Point ;
the points must have the same dimension |
option1, option2, ... |
- | plot option(s) of the form OptionName =
value |
plot
, plot2d
, plot3d
, plot::copy
plot::Pointlist
represent
graphical primitives for lists of two- or three-dimensional points that
can be displayed via plot
, or used with other graphical
primitives of the plot
library.p1
, p2
... of the represented list
which are not given as objects of the domain plot::Point
, are converted into objects
of this domain. See the help page of this domain for information about
the default plot options used in this case.plot::Pointlist
has type
"graphprim"
, i.e., if o
is such an object,
then the result of type(o)
is the string
"graphprim"
.option1
, option2
... are specified
by equations OptionName = value
. The following table gives
an overview of the available options:
OptionName |
admissible values | default value |
Color | [Flat] , [Flat, [r,g,b]] , [Height] , [Height, [r,g,b], [R,G,B]] , [Function, f] |
[Height] |
DrawMode | None, Connected, Horizontal, Vertical, set of these values | None |
LineStyle | SolidLines, DashedLines | SolidLines |
LineWidth | positive integers | 1 |
PointStyle | Circles, FilledCircles, FilledSquares, Squares | FilledSquares |
PointWidth | positive integers | 30 |
Title | strings | |
TitlePosition | [x, y] |
|
plot2d
for further
details on each option, except of DrawMode that
is explained in detail below.plot::Point
. See example 2.Scene options for the parameters
option1
, option2
... are not allowed! One may
pass scene options to the function plot
, or use plot::Scene
to create an object
representing a graphical scene.
::
.
Each attribute has the property ``read'', i.e., the value of an
attribute attr
of a graphical primitive o
can
be read with o::attr
. If the attribute also has the
``write'' property, then the value of the attribute can be changed with
o::attr := new_value
.
The following attributes are available for a point-list primitive:
attribute | meaning | properties |
objects |
A list of objects of the domain plot::Point , the points of the
point-list primitive. The initial value is the list [p1,
p2...] of the parameters p1 , p2 ...,
where each parameter was converted into an object of the domain
plot::Point .
Note that if you extract an object of this list and do some changes
on this object, then you must set the value of the attribute
|
read/write |
options |
A table of plot options of the point-list primitive.
Note that if you change the value of this attribute, the entries of the
assigned table are not checked to be valid plot options for point-list
primitives. Invalid entries lead to runtime errors.
The initial value of this attribute is the table stored under the
domain entry |
read/write |
plotdata |
List of the plot data of the point-list primitive in a
plot2d and plot3d conforming syntax,
respectively (see the method "getPlotdata" below). Note
that the value of this attribute should only be used if the attribute
refreshPlotdata has the value FALSE (see
below). |
read |
refreshPlotdata |
A boolean value which signals whether the plot data of
the point-list primitive must be (re-)build with the method
"getPlotdata" (see below). If its value is
FALSE , then the plot data of the point-list primitive is
stored in the attribute plotdata . The initial value is
TRUE . |
read/write |
plot::Curve2d
for examples for working
with attributes of graphical primitives.value
modes
enables the
modes given in the set modes
.
For example, with DrawMode= {Horizontal, Vertical}
, a line
from the x-axis to each point and a line from the
y-axis to each point is drawn.The operands of an object of plot::Pointlist
are the
parameters p1
, p2
... (in this order).
Operands of a point-list primitive can be accessed either using the
system function op
, the
index operator [ ]
, or
using the attribute objects
described above. For
example, if pointlist
is such an object, then the calls
op(pointlist,1)
, pointlist[1]
and
pointlist::objects[1]
return the first point of
pointlist
.
Via pointlist[1] := new_point
or
pointlist::objects[1] := new_point
, the first point of
pointlist
is replaced by new_point
.
See the methods "op"
, "_index"
,
"set_index"
and "slot"
below.
Use the slot operator ::
to get or set plot options of
such objects afterwards, i.e., when they have been created. For
example, if pointlist
is such an object, then
pointlist::Color := RGB::Red
changes the color of each
point of pointlist
to red.
Evaluating an object of type plot::Pointlist
returns
itself.
Calling an object of plot::Pointlist
primitive as a
function yields the object itself, regardless of the arguments. The
arguments are not evaluated.
is a table of plot options for point-list primitives and their
default values. Each entry has the form OptionName =
default_value
.
When an object of the domain plot::Pointlist
is
created, then a copy of this table is stored under the attribute
options
(see the table of attributes above), where those
options are added and replaced, respectively, which are given by the
(optional) parameters option1
, option2
... of
the creating call (see ``Creating Elements'' above).
Plot options, which are not contained in the table stored under the
attribute options
will not be included in the plot data of
the object created by the method "getPlotdata"
(see
below).
For those options, the corresponding default value either is set by
a graphical scene, if the option also
exists as a scene option (such as the option PointWidth), or it is internally set by the function
plot2d
and plot3d
, respectively, which are
used to plot the object. See the table of plot options above, which
gives a summary of the available plot options for point-list primitives
and their default values.
To change the default value of some plot options, the option name
and its default value may be added to the table
"defaultOptions"
, or replaced by a new value,
respectively.
is a set of the available option names for plots of point-lists.
_index(dom pointlist, positive integer i)
i
th point of pointlist
. If
i
is greater than the number of points of
pointlist
, then FAIL
is returned._index
, i.e., one may use it in the
form pointlist[i]
, or in functional notation
_index(pointlist, i)
.dimension(dom pointlist)
getPlotdata(dom pointlist)
pointlist
in a plot2d
and plot3d
conforming syntax,
respectively, i.e., it has the form [Mode = List, [point(...),
...]]
.
For example, with s :=
plot::Pointlist::getPlotdata(pointlist)
the call
plot2d(s[1])
and plot3d(s[1])
, respectively,
gives a plot of pointlist
.
options
(see the table of attributes above). For any other
plot option not contained in this table, the corresponding default
value set by the function plot2d
and plot3d
, respectively, for lists of
primitives is used when plotting the object.plotdata
of pointlist
.refreshPlotdata
of pointlist
to
FALSE
.plot::Scene
to build the plot data of
the graphical scene.nops(dom pointlist)
pointlist
.nops
, i.e., one may use it in the form
nops(pointlist)
.op(dom pointlist, positive integer i)
i
th point of pointlist
. If
i
is greater than the number of points of
pointlist
, then FAIL
is returned.op
, i.e., one may use it in the form
op(pointlist, i)
.set_index(dom pointlist, positive integer i, plot::Point
p)
i
th point of pointlist
by
the point p
.i
is greater than the number of coordinates of
pointlist
, or if p
not an object of the
domain plot::Point
, then a
warning message is issued. In this case the call of this method has no
effect on the object pointlist
.refreshPlotdata
of pointlist
to
TRUE
.slot(dom pointlist, string slotname)
slotname
of
pointlist
. slotname
may either be the name of
an attribute or the name of a plot option. See the tables of available
plot options and attributes above.slotname
is the name of a plot option, but the
option is not contained in the table stored under the attribute
options
, then FAIL
is returned.
If slotname
is an invalid attribute or option, then an
error message is issued.
slot
, i.e., one may use it in the form
pointlist::slotname_id
(here, slotname_id
must be the identifier corresponding to the string
slotname
), or in functional notation slot(pointlist,
slotname)
.slot(dom pointlist, string slotname, any val)
slotname
to the value val
.slotname
, or if val
is not an admissible
value for slotname
, then a warning message is issued. In
this case, the value of slotname
remains unchanged.slot
, i.e., one may use it in the form
pointlist::slotname_id := val
(here,
slotname_id
must be the identifier corresponding to the
string slotname
), or in functional notation
slot(pointlist, slotname, val)
.refreshPlotdata
of
point
is set to TRUE
.checkOption(equation OptionName =
value)
OptionName
is a known plot
option for point-list primitives (see the table of available plot
options above), and value
is an admissible value for this
option.[TRUE, OptionName,
newValue]
is returned. Note that the value of the option could
have been converted into an admissible format. Thus,
newValue
must be used as the value of the option
OptionName
instead of value
.[FALSE, error_msg]
is returned.
The string error_msg
is a description of the located
problem, which can be passed, for example, to the system function
error
to raise a
user-specified exception.copy(dom pointlist)
pointlist
.plot::copy
. See its help page for
details.expose(dom pointlist)
pointlist
.expose
, i.e., one may use it in the
form expose(pointlist)
.modify(dom pointlist, equation(s) Name1 = value1...)
pointlist
and changes the
slots Name1
... of this copy to the new values
value1
...Name1
... must be names of attributes
or plot options of the domain plot::Pointlist
. Otherwise a
warning message is issued, and the slot remains unchanged. Also, if one
of the values value1
... is not an admissible value for the
corresponding attribute or plot option, respectively, the change of the
slot is ignored.
See the tables of available options and attributes above.
refreshPlotdata
of the copy of pointlist
to
TRUE
.plot::modify
.print(dom pointlist)
plot::Pointlist()
. It is used to print objects of
plot::Pointlist
to the screen.expose(pointlist)
to expose the
points of pointlist
.print
for details.This example illustrates the different modes for plotting lists of points. We start with the default mode, that is plotting each point of the list in the order as specified:
>> p1 := plot::Pointlist( plot::Point(i, exp(i)) $ i = 1..5 )
plot::Pointlist()
To plot the list of points created, call:
>> plot(p1)
If you want to connect every two points by a line, then
use the option DrawMode=Connected
:
>> p2 := plot::Pointlist( plot::Point(i, exp(i)) $ i = 1..5, DrawMode = Connected ): plot(p2)
Set the value of the option DrawMode to Vertical or Horizontal in order to draw a line from the x-axis and the y-axis, respectively, to each point of the list:
>> p2::DrawMode := Vertical: plot(p2)
>> p2::DrawMode := Horizontal: plot(p2)
Here, we used the slot operator ::
to
change the value of some plot options of the graphical primitive
p2
.
One can also combine plot modes for lists of points, such as plotting vertical and horizontal lines to each point:
>> p2::DrawMode := {Horizontal, Vertical}: plot(p2)
One can specify plot options for each point of the list. For example, to plot the points of a list in different sizes, enter:
>> p := plot::Pointlist( plot::Point(i, sin(i), PointWidth = 10*i) $ i = 1..10 ): plot(p)
A plot option of the object p
acts on every
point of the list, except of the points of the list, for which a plot
option is set explicitely.
For example, if we change the value of the option Color of the object p
to blue, then every
point is drawn in blue color:
>> p::Color := RGB::Blue: plot(p)
To set the color option for some points explicitely, such as changing the color of the last point to red, one may enter:
>> (p[10])::Color := RGB::Red: plot(p)
The plot options of a plot-list object (here:
p
) also act on the connecting lines, if the option DrawMode is used.
For example, if we create a point-list and set the color of the
points explicitely to blue, then connecting lines are still drawn in
the default color of objects of the domain
plot::Pointlist
, i.e., in red color:
>> p2 := plot::Pointlist( plot::Point(i, i^2, Color = RGB::Blue) $ i = -5..5, DrawMode = Connected ): plot(p2)