plot::vectorfield
--
generate plots of two-dimensional vector fieldsplot::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].
plot::vectorfield([v1, v2], x = a..b, y = c..d <, option1,
option2...>)
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 |
plot(...)
to display the result on the
screen.option1
, option2
... must
be valid plot options for two-dimensional graphical objects. See
plot2d
for details.
Note that scene options are not allowed! You may
give scene options as optional arguments for the function plot
, or use plot::Scene
to create an object
representing a graphical scene.
Scaling = Constrained
.
For Scaling = UnConstrained
, you can resize the plot
window and change the scaling.
So the user is advised to use Scaling = Constrained
for
a nice graphical appearance of the arrows, whenever this is
appropriate.
However, if the scale ratio (ymax-ymin)/(xmax-xmin) of
the viewing box is not close to one, then Scaling =
Constrained
is usually not appropriate. If you do not like the
arrows, then you must re-parameterize the vector field such that the
scale ratio in the new x-y parameters is close to one.
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 )
plotlib::fieldplot
plot::vectorfield
is now part of the new plot library
plot
, and its calling
syntax and the return value were changed.