Previous Page Next Page Contents

plot::Scene -- a graphical scene

Introduction

plot::Scene(object1, object2...) combines the graphical objects object1, object2 etc. to a graphical scene.

Creating Elements

plot::Scene(object1 <, object2...> <, option1, option2...>)

Parameters

scene - a graphical scene: an object of domain type plot::Scene
object1, object2, ... - 2D or 3D graphical objects
option1, option2, ... - scene options of the form OptionName = value

Related Domains

RGB

Related Functions

plot, plot2d, plot3d, plot::copy

Details

Operands

The operands of an object of plot::Scene are the parameters object1, object2... (in this order).

Important Operations

Operands of a graphical scene can be accessed either using the system function op, the index operator [ ], or using the attribute objects described above. For example, if scene is such an object, then the calls op(scene,1), scene[1] and scene::objects[1] return the parameter object1.

Via scene[1] := g, the first object of the scene is replaced by the graphical primitive g (that must be of the type "graphprim").

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 scene is such an object, then scene::Axes := None removes the axes in the graphical scene.

Result of Evaluation

Evaluating an object of type plot::Scene returns itself.

Function Call

Calling an object of plot::Scene as a function yields the object itself, regardless of the arguments. The arguments are not evaluated.

Entries

defaultOptions2d

is a table of plot options for two-dimensional graphical scenes and their default values. Each entry has the form OptionName = default_value.

When an object of the domain plot::Scene 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... 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 internally set by the function plot2d is used when plotting the object. See the table of plot options above, which gives a summary of the available plot options for two-dimensional graphical scenes 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.

optionNames2d

is a set of the available option names for plots of two-dimensional graphical scenes.

defaultOptions3d

is a table of plot options for three-dimensional graphical scenes and their default values. Each entry has the form OptionName = default_value.

When an object of the domain plot::Scene 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... 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 internally set by the function plot3d is used when plotting the object. See the table of plot options above, which gives a summary of the available plot options for three-dimensional graphical scenes 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.

optionNames3d

is a set of the available option names for plots of three-dimensional graphical scenes.

Method _index: indexed access to the operands of a graphical scene

Method dimension: dimension of a graphical scene

Method getPlotdata: create the plot data of a graphical scene

Method nops: number of operands of a graphical scene

Method op: extract operands of a graphical scene

Method set_index: set operands of a graphical scene

Method slot: read and write attributes and plot options

Method checkOption2d: check a plot option

Method checkOption3d: check on plot options

Method copy: create a copy of a graphical scene

Method expose: expose the definition of a scene

Method modify: modify a copy of a graphical scene

Method print: print a graphical scene

Example 1

The following calls return objects representing the graphs of the sinus and cosinus function in the interval [0, 2*PI]:

>> f1 := plot::Function2d(sin(x), x = 0..2*PI);
   f2 := plot::Function2d(
     cos(x), x = 0..2*PI, Color = RGB::Blue
   )
                   plot::Function2d(sin(x), x = 0..2 PI)
      
                   plot::Function2d(cos(x), x = 0..2 PI)

The call plot(f1, f2) displays these graphs f1 and f2. In fact, the function plot first creates a graphical scene consisting of these two graphs as follows:

>> s := plot::Scene(f1, f2)
                               plot::Scene()

and then displays this scene:

>> plot(s)

To change default values of some scene options, pass the scene options to the call of plot::Scene as additional arguments, or, if an object of plot::Scene is already created, change the value of the corresponding option with the slot operator :: and call plot again to display the changed object.

For example, to draw grid lines in the background of the plot of the graphical scene s created in the previous input, we enter:

>> s::GridLines := Automatic: 
   plot(s)

Example 2

We create a graphical scene consisting of a graph of the sequence n -> sin(n)/n in the interval [1, 50], enclosed by the graphs of the functions x -> 1/x and x -> -1/x:

>> s := plot::Scene( 
     plot::Function2d(1/x, x = 1..50),
     plot::Pointlist([n, sin(n)/n] $ n = 1..50, Color = RGB::Blue),
     plot::Function2d(-1/x, x = 1..50)
   )
                               plot::Scene()

We plot the scene:

>> plot(s)

One can access the graphical primitives of a graphical scene using the index operator []. For example, the sequence created above is the second operand of the scene s:

>> pl := s[2]
                             plot::Pointlist()

Any change of the object pl, for example, a change of some plot options, reacts on the plot of the scene s:

>> pl::PointWidth := 15: plot(s)

This is due to the reference effect for domains. If changes of an object should not reflect the scene in that the object is contained, one must first explicitly create a copy of the corresponding object using the function plot::copy:

>> pl2 := plot::copy(pl)
                             plot::Pointlist()

Now changes on the object pl2 do not react on the object pl of the graphical scene s. For example, if we change the draw mode of the point list pl2 in order to connect every two points of the point list by a line, the plot of the scene s remains unchanged:

>> pl2::DrawMode := Connected: plot(s)

whereas the copied object pl2 is displayed as follows:

>> plot(pl2)

Example 3

This example illustrates how to read and write attributes of graphical scenes (see the table of available attributes in ``Details'' above).

Plot options, which are explicitly set for a graphical scene, are stored under the attribute options and can be read with the slot operator :::

>> s := plot::Scene( 
     plot::Curve2d([sin(x), cos(x)], x = 0..2*PI),
     Axes = Box
   ):
   s::options
             table(
               TitlePosition = Above,
               PointWidth = 30,
               LineStyle = SolidLines,
               AxesScaling = [Lin, Lin],
               Axes = Box,
               BackGround = [1.0, 1.0, 1.0],
               Ticks = Automatic,
               ViewingBox = Automatic,
               RealValuesOnly = FALSE,
               Labeling = TRUE,
               Discont = FALSE,
               GridLinesStyle = DashedLines,
               ForeGround = [0.0, 0.0, 0.0],
               AxesOrigin = Automatic,
               LineWidth = 1,
               PointStyle = FilledSquares,
               GridLines = None,
               Arrows = FALSE,
               GridLinesWidth = 1,
               Scaling = UnConstrained,
               GridLinesColor = [0.752907, 0.752907, 0.752907]
             )

These are default values of some options of two-dimensional graphical scenes, defined by the entry "defaultOptions2d" of the domain plot::Scene:

>> plot::Scene::defaultOptions2d
             table(
               TitlePosition = Above,
               PointWidth = 30,
               LineStyle = SolidLines,
               AxesScaling = [Lin, Lin],
               Axes = Origin,
               BackGround = [1.0, 1.0, 1.0],
               Ticks = Automatic,
               ViewingBox = Automatic,
               RealValuesOnly = FALSE,
               Labeling = TRUE,
               Discont = FALSE,
               GridLinesStyle = DashedLines,
               ForeGround = [0.0, 0.0, 0.0],
               AxesOrigin = Automatic,
               LineWidth = 1,
               PointStyle = FilledSquares,
               GridLines = None,
               Arrows = FALSE,
               GridLinesWidth = 1,
               Scaling = UnConstrained,
               GridLinesColor = [0.752907, 0.752907, 0.752907]
             )

When the plot data of a graphical scene is created (calling the method "getPlotdata"), only those plot options are used that are contained in the table s::options:

>> plot::Scene::getPlotdata(s)
      [TitlePosition = Above, PointWidth = 30,
      
         LineStyle = SolidLines, AxesScaling = [Lin, Lin],
      
         Axes = Box, BackGround = [1.0, 1.0, 1.0],
      
         Ticks = Automatic, ViewingBox = Automatic,
      
         RealValuesOnly = FALSE, Labeling = TRUE, Discont = FALSE,
      
         GridLinesStyle = DashedLines, ForeGround = [0.0, 0.0, 0.0],
      
         AxesOrigin = Automatic, LineWidth = 1,
      
         PointStyle = FilledSquares, GridLines = None,
      
         Arrows = FALSE, GridLinesWidth = 1,
      
         Scaling = UnConstrained, GridLinesColor =
      
         [0.752907, 0.752907, 0.752907],
      
         [Mode = Curve, [sin(x), cos(x)], x = [0.0, 6.283185307],
      
         Grid = [100], Color = [Flat, [1.0, 0.0, 0.0]]]]

This means that for any other available scene option not contained in the table s::options (e.g., the option Title), the default value is internally set by the function plot2d when plotting the scene.

Use delete to remove plot options set for a graphical scene:

>> delete s::options[Axes]: s::options
             table(
               TitlePosition = Above,
               PointWidth = 30,
               LineStyle = SolidLines,
               AxesScaling = [Lin, Lin],
               BackGround = [1.0, 1.0, 1.0],
               Ticks = Automatic,
               ViewingBox = Automatic,
               RealValuesOnly = FALSE,
               Labeling = TRUE,
               Discont = FALSE,
               GridLinesStyle = DashedLines,
               ForeGround = [0.0, 0.0, 0.0],
               AxesOrigin = Automatic,
               LineWidth = 1,
               PointStyle = FilledSquares,
               GridLines = None,
               Arrows = FALSE,
               GridLinesWidth = 1,
               Scaling = UnConstrained,
               GridLinesColor = [0.752907, 0.752907, 0.752907]
             )

Now the value of the option Axes is the default value set by plot2d (which is the value Origin), or read from the preferences of the MuPAD's graphic tool VCam:

>> plot(s)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000