Previous Page Next Page Contents

plot2d -- 2D plots

Introduction

plot2d(object1, object2, ...) generates a 2D plot of graphical objects such as parametrized curves, points, and polygons.

Call(s)

plot2d( <SceneOptions,> object1, object2, ...)

Parameters

object1, object2, ... - graphical objects as described below

Options

SceneOptions - a sequence of scene options. These determine the general appearance of the graphical scene. See ?plotOptions2d for details.

Returns

MuPAD's graphics tool is called to render the graphical scene, and the null() object is returned to the MuPAD session.

Related Functions

plot, plotfunc2d, plot3d, plotfunc3d

Details

Option: Color =

value

Option: Grid = [n]

Option: LineStyle =

value

Option: LineWidth = n

Option: PointStyle =

value

Option: PointWidth = n

Option: Smoothness = [n]

Option: Style =

value

Option: Title =

TitleString

Option: TitlePosition = [x, y]

Example 1

We plot a semi-circle of radius 1, parametrized by the polar angle u. The scene option Scaling = Constrained ensures that the circle is not deformed to an ellipse:

>> plot2d(Scaling = Constrained, Labeling = TRUE,
          [Mode = Curve, [cos(u), sin(u)], u = [0, PI]])

Example 2

We define two point primitives, a line primitive and a filled polygon:

>> point1 := point(1, 1, Color = RGB::Red):
   point2 := point(-1, 1, Color = RGB::Green):
   line := polygon(point(1, 0), point(0, 1), point(0, 0), 
                   Color = RGB::Blue):
   triangle := polygon(point(0, 0), point(0, 1), point(-1, 0),
                       Closed = TRUE, Filled = TRUE,
                       Color = RGB::Antique): 

These are combined to a graphical object:

>> object := [Mode = List, [point1, point2, line, triangle]]:

Finally, this object is plotted:

>> plot2d(BackGround = RGB::White, PointWidth = 50,
          PointStyle = FilledCircles, object)
>> delete point1, point2, line, triangle, object:

Example 3

The graph of the sine function is diplayed using different styles:

>> plot2d(BackGround = RGB::White, ForeGround = RGB::Black,
          Labeling = TRUE, PointWidth = 50,
          [Mode = Curve, [x, sin(10*x)], x = [0, 1],
           Color = [Flat, RGB::Red], Grid = [50], Smoothness = [0],
           PointStyle = FilledSquares, Style = [Points]
          ],
          [Mode = Curve, [x, 0.1 + sin(10*x)], x = [0, 1],
           Color = [Flat, RGB::Green],
           Grid = [20], Smoothness = [1],
           PointStyle = FilledCircles, Style = [LinesPoints]
          ],
          [Mode = Curve, [x, 0.2 + sin(10*x)], x = [0, 1],
           Color = [Flat, RGB::Blue], Grid = [100], Style = [Lines]
          ])

Example 4

We demonstrate the ViewingBox option.

>> spiral := [Mode = Curve, [u*cos(u), u*sin(u)], u = [0, 2*PI],
              Grid = [50]]:

First, this object is plotted without clipping:

>> plot2d(Axes = Box, Labeling = TRUE, spiral)

In the next plot, the object is clipped to the horizontal range x = -4..1 and the vertical range y = -2..2:

>> plot2d(Axes = Box, Labeling = TRUE, 
          ViewingBox = [-4..1, -2..2], spiral)
>> delete spiral:

Example 5

We demonstrate user-defined color functions. The following function produces admissible RGB-values between 0 and 1 for objects with coordinates from the range x=0..1 and y=0..1:

>> myColor := (x, y) -> [x, 0.5 + abs(x - y)/(1 + x + y), y]:

The unit square is to be colored by the function above. We cover the square by 2*n^2 triangles, each of which is displayed with a flat color determined by myColor:

>> n :=  30:
   plot2d([Mode = List,
           [polygon(point((i-1)/n, (j-1)/n),
                    point((i-1)/n,   j  /n),
                    point(  i  /n,   j  /n),
                    Filled = TRUE
                    ) $ i = 1..n $ j = 1..n,
            polygon(point((i-1)/n, (j-1)/n),
                    point(  i  /n, (j-1)/n),
                    point(  i  /n,   j  /n),
                    Filled = TRUE
                    ) $ i = 1..n $ j = 1..n
           ],
           Color = [Function, myColor]
          ]):
>> delete myColor, n:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000