Previous Page Next Page Contents

plot::vectorfield -- generate plots of two-dimensional vector fields

Introduction

plot::vectorfield([v1, v2], x = a..b, y = c..d) represents a plot of the vectorfield defined by (x,y) -> (v1(x,y); v2(x,y)) with (x,y) in [a,b] x [c,d].

Call(s)

plot::vectorfield([v1, v2], x = a..b, y = c..d <, option1, option2...>)

Parameters

v1, v2 - arithmetical expressions in x and y (the x- and y-component of the vectorfield)
x, y - identifiers
a, b, c, d - real numerical values
option1, option2, ... - plot option(s) for two-dimensional graphical objects

Related Functions

plot, plot2d

Details

Example 1

We demonstrate a plot of the vector field v(x,y) = [1, sin(x)+cos(y)].

>> DIGITS:=5:
   field:= plot::vectorfield(
     [1,sin(x)+cos(y)], x = 0..3, y = 1..2,
     Grid=[30,20], Color = [Flat, RGB::Red]
   )
                               plot::Group()

It is the directional field associated with the ode y'(x) = sin(x)+cos(y). We insert a curve representing the numerical solution of this ode into this plot. We compute the numerical solution of y'(x)=sin(x)+cos(y), y(1)=1.2 via numeric::odesolve. DIGITS is increased to get rich sample of points:

>> DIGITS:=20: 
   f:= (x,y) -> [sin(x)+cos(y[1])]:
   data:= numeric::odesolve(1..2, f, [1.2], Alldata):
>> curve:= plot::Polygon(
     (
       [data[i][1], data[i][2][1]], [data[i+1][1], data[i+1][2][1]]
     ) $ i=1..nops(data)-1, 
     Color = RGB::Blue
   )
                              plot::Polygon()

Define a circle with center (1.5; 1.5)) and radius 1/2:

>> circle:= plot::Ellipse2d([1.5,1.5], 1/2, 1/2 ):

We plot the three objects in a single graphical scene:

>> plot(field, circle, curve, 
      Axes = Box, Labeling = TRUE, Scaling = Constrained
   )

Compare the plot when setting Scaling = UnConstrained:

>> plot(field, circle, curve, 
     Axes = Box, Labeling = TRUE, Scaling = UnConstrained
   )

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000