Previous Page Next Page Contents

plotfunc2d -- 2D plots of function graphs

Introduction

plotfunc2d(f1, f2, ...) generates a 2D plot of the graphs of the univariate functions f1, f2 etc.

Call(s)

plotfunc2d( <SceneOptions,> f1, f2, ... <, Grid = n> )
plotfunc2d( <SceneOptions,> f1, f2, ..., x = xmin..xmax <, Grid = n>)
plotfunc2d( <SceneOptions,> f1, f2, ..., x = xmin..xmax, y = ymin..ymax <, Grid = n>)

Parameters

f1, f1, ... - the functions: arithmetical expressions or piecewise objects containing one indeterminate x
x - the horizontal coordinate: an identifier
xmin, xmax - the horizontal plot range: finite real numerical expressions
y - a dummy name for the vertical coordinate: an identifier. This name is used to label the y-axis.
ymin, ymax - the vertical plot range: finite real numerical expressions

Options

SceneOptions - a sequence of scene options. These determine the general appearance of the graphical scene. See ?plotOptions2d for details.
Grid = n - sets the number of sample points used for the plot. The integer n must be larger than 1; the default is Grid = 100.

Returns

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

Related Functions

plot, plot::Function2d, plot2d, plot3d, plotfunc3d

Details

Option: Grid = n

Example 1

The following command draws the sine and the cosine functions on the interval [-PI, PI]:

>> plotfunc2d(sin(x), cos(x), x = -PI..PI):

Example 2

Only real functions values are plotted:

>> plotfunc2d(sqrt(1 - x), sqrt(x), x = -2..2): 

Example 3

The following functions have singularities in the specified interval:

>> plotfunc2d(x/(x^3 - 4*x), x = -5..5): 
>> plotfunc2d(1/sin(x), tan(x), x = 0..2*PI):

Example 4

We define a vertical range to which the function graph is restricted:

>> plotfunc2d(tan(x), x = -3..3, y = -10..10):

Example 5

The following function has a jump discontinuity:

>> plotfunc2d((x^2 - x)/(2*abs(x - 1)), x = -3..3, y = -3..3)

Example 6

Piecewise defined functions are handled:

>> f := piecewise([x < 1, -x^2 + 1], [x >= 1, x]):
   plotfunc2d(BackGround = RGB::White,
              ForeGround = RGB::Black,
              GridLines = Automatic,
              Ticks = [Steps = 1, Steps = 1], 
              f(x), x = -3..3, y = -3..3)
>> f := piecewise([x <= 0, x], [x > 0, 1/x]):
   plotfunc2d(BackGround = RGB::White,
              ForeGround = RGB::Black,
              GridLines = Automatic,
              Ticks = [Steps = 1, Steps = 1], 
              f(x), x = -3..3, y = -3..3)
>> delete f:

Example 7

We use the scene option AxesScaling to create a logarithmic plot:

>> plotfunc2d(AxesScaling = [Lin, Log], x^2, x^3, x = 1/10..10^3):

We demonstrate various further scene options in a doubly logarithmic plot:

>> plotfunc2d(Axes = Box,
              AxesScaling = [Log, Log],
              Discont = FALSE,
              BackGround = RGB::White,
              ForeGround = RGB::Black,
              GridLines = Automatic,
              GridLinesStyle = SolidLines,
              GridLinesColor = RGB::Gray,
              Ticks = [[10^i $ i = -1..3], [10^i $ i = -3..9]],
              x^2, x^3/(1 + x^(1/2)), x^3, x = 1/10..10^3):

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000