Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

T / MAXIMA / DOC / Graphics_with_Maxima-2011

.pdf
Скачиваний:
49
Добавлен:
21.05.2015
Размер:
1.14 Mб
Скачать

4 Graphic Interface Draw

19

XPM-files, color channels can be extracted from images, images can be composed from color channels [1], [3].

4.3 3d-graphic objects

explicit(f(x,y),x,x1,x2,y,y1,y2)

Function f(x,y) within the ranges x1. . . x2 and y1. . . y2

implicit(equation,x,x1,x2,y,y1,y2,z,z1,z2)

Implizit curve defined by equation, in the variables x, y and z within the ranges x1. . . x2, y1. . . y2, z1. . . z2

parametric(x(t),y(t),z(t),t,t1,t2)

Parametric curve x(t),y(t),z(t) with the parameter t ranging from t1 to t2

parametric_surface(x(u,v),y(u,v),z(u,v),u,u1,u2,v,v1,v2)

Parametric surface x(u,v),y(u,v),z(u,v) with the parameters u and v within the ranges u1. . . u2 and v1. . . v2

cylindrical(r(z,ϕ),z,z1,z2,ϕ,ϕ1,ϕ2)

Surface in zylindric coordinates; radius r(z,ϕ) with respect to the z-coordinate z ranging from z1 to z2 and azimuth ϕ ranging from ϕ1 to ϕ2

spherical(r(ϕ,ϑ),ϕ,ϕ1,ϕ2,ϑ,ϑ1,ϑ2)

Surface in spherical coordinates; radius r(ϕ,ϑ) with respect to the azimuth ϕ ranging from ϕ1 to ϕ2 and the zenith ϑ ranging from ϑ1 to ϑ2

points(xvals,yvals,zvals) Points; xvals, yvals and zvals are lists containing the x-, y- and z-values respectively

points(p1,p2,...) Points; each point pi is a list containing its coordinates:

[px,py,pz].

label(["text",x,y,z],...) Text label text at the position [x,y,z]; alignment, font etc. can be set using options.

vector([x,y,z],[dx,dy,dz]) Vector with the origin [x,y,z] and its coordinates [dx,dy,dz]

3d-graphic objects

explicit and implicit define graphic objects by mathematical expressions in cartesian coordinates as surfaces in three-dimensional space. parametric defines a parametric curve with the parameter t, parametric_surface defines a surface in parametric form with two parameters u and v. cylindrical and spherical define a surface in cylindric and spheric coordinates respectively.

Contrary to the Gnuplot interface Plot, one single diagramm can contain any number of graphic objects.

Wilhelm Haager: Graphics with MAXIMA

(2 − 0.5 cos (t)) ,

4 Graphic Interface Draw

20

Sphere, defined as an implicit function

Two-dimensional function

Drawing the sphere and the two-dimensional function into one diagram. The option surface_hide supresses hidden parts.

Toroidal spiral as parametric curve with four windings around a toroid

Toroid as 3d-surface in parametric form

Common display of toroid and spiral

(%i37) gimp:implicit(1=x**2+y**2+z**2, x,-1,1,y,-1,1,z,-1,1);

€ Š

(%o37) implicit 1 = z2 + y2 + x2, x, −1, 1, y, −1, 1, z, −1, 1

(%i38) gexp:explicit(sin(2*x)*sin(2*y),x,-2,2,y,-2,2);

(%o38) explicit sin (2 x) sin 2 y , x, −2, 2, y, −2, 2

(%i39) wxdraw3d(surface_hide=true, color=red,gexp,color=blue,gimp)$

(%t39)

(%i40) spiral:parametric((2-0.5*cos(t))*sin(t/4), (2-0.5*cos(t))*cos(t/4), 0.5*sin(t),t,0,8*%pi);

t

(%o40) parametric sin

 

(2 − 0.5 cos (t)) ,

4

t

 

 

cos

4

0.5 sin (t) , t, 0, 8 π)

(%i41) torus:parametric_surface( (2-0.2*cos(phi))*sin(theta), (2-0.2*cos(phi))*cos(theta), 0.2*sin(phi),phi,0,2*%pi,theta,0,2*%pi);

(%o41)

 

 

 

 

 

parametric_surface

2 − 0.2 cos ϕ

sin (ϑ) ,

 

 

 

 

 

 

2 − 0.2 cos ϕ

cos (ϑ) , 0.2 sin ϕ

,

 

ϕ, 0, 2 π, ϑ, 0, 2 π

 

 

 

(%i42)

wxdraw3d(nticks=200,surface_hide=true,

 

 

color=orange,torus,

 

 

 

line_width=2,color=blue,spiral)$

(%t42)

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

21

Cone as a function in cylindric coordinates

Snail shell like surface, defined in spheric coordinates

Common display of cone and snail shell

3d-points in the xy-plane, shaping a circle

Four vectors, forming a compass rose

Texts in three-dimensional space; the text is not aligned to the axes, but to the view direction.

3d-graphic containing points, vectors and texts

(%i43) cone:cylindrical( (z-15)*0.05,z,-15,15,phi,0,2*%pi);

(%o43) cylindrical 0.05 (z − 15) , z, −15, 15, ϕ, 0, 2 π

(%i44) snail:spherical(4+0.5*phi,phi, -2*%pi,%pi,tht,0,%pi);

(%o44) spherical 0.5 ϕ + 4, ϕ, −2 π, π, tht, 0, π

(%i45) wxdraw3d(surface_hide=true,color=green,cone, color=brown,snail)$

(%t45)

(%i46) pts:points(makelist( [sin(t*%pi/10),cos(t*%pi/10),0],t,1,20))$

(%i47) [v1,v2,v3,v4]:[vector([0,0,1],[0.7,0,0]), vector([0,0,1],[0,0.7,0]),vector([0,0,1], [-0.7,0,0]),vector([0,0,1],[0,-0.7,0])];

(%o47) [vector ([0, 0, 1], [0.7, 0, 0]) , vector ([0, 0, 1], [0, 0.7, 0]) , vector ([0, 0, 1], [−0.7, 0, 0]) , vector ([0, 0, 1], [0, −0.7, 0])]

(%i48) text:label(["North",0,1,1],["East",1,0,1], ["South",0,-1,1],["West",-1,0,1]);

(%o48) label ([N or th, 0, 1, 1], [East, 1, 0, 1], [South, 0, −1, 1] , [West, −1, 0, 1])

(%i49) wxdraw3d(color=red,pts,color=orange, v1,v2,v3,v4,color=blue,text)$

(%t49)

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

22

4.4 General Options

set_draw_defaults(opts,. . . ) Declares default values for options

terminal=term output format for the graphic; possible values: screen

(default), png, jpg, eps, eps_color, pdf.

file_name="file" output target for the graphic; default: maxima_out

user_preamble="text" Gnuplot preamble; contains arbitrary Gnuplot commands, which precede the actual plot process

dimensions=[width,height] Size of the graphic: in pixels for pixel graphics, in 1/10 mm for vector graphics

columns=n Number of columns for several scenes in one single graphic

color=colorname Line color

background_color=name Background color of the diagram

fill_color=name Fill color of rectangles, polygons and circles

x(yz)range=[min,max] Coordinate range of the x(yz)-axis

logx(yz)=true/false Logarithmic scale of the x(yz)-axis

grid=true/false Drawing grid lines, if true

x(yz)tics=true/false Controls the way tic marks are drawn on the x(yz)-axis x(yz)tics_rotate=true/false Determines, whether tic marks are rotated by 90

title="text" Main title for the scene (default: empty string)

key="text" Name of a function in the legend (def.: empty string)

x(yz)label="text" Label for the x(yz)-axis

x(yz)axis=true/false Determines,whether a x(yz)-axis is to be drawn

x(yz)axis_width=width Line width of the respective axis x(yz)axis_color=color Color of the respective axis

x(yz)axis_type=solid/dots Line type of the respective axis: solid line (solid) or dotted (dots), default: dots

line_width=width Line width

line_type=solid/dots Line type (default: solid)

point_size=size Point size in point-plots

point_type=n Point type, possible values: 1,0,1,2,. . . 13.

points_joined=true/false Determines, whether points are connected by line segments (default: false)

nticks=n Number of initial points used by the adaptive plotting routine (default: 30)

adapt_depth=n Maximum number of splittings used by the adaptive plotting routine (default: 10)

General plot options of the Gnuplot interface Draw

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

23

set_draw_defaults declares default values for arbitrary options, calling that command with an empty parameter list (set_draw_defaults()), resets all options to their original default.

Options can be aggregated in lists, those lists can be included—even nested—into the parameter list of a plot command in place of single options.

terminal and file_name declare output format and output target of the graphic. Th possible output formats do not correspond to the Gnoplot terminals as stated in section 2.2. The file name (default: maxima_out) must not have an extension, the appropriate file extension (.eps,

.png, .jpg) will be added by Maxima automatically. Unless the path name is given, the file will be saved into the Gnuplot working directory. Declaring terminal or file_name within the wx-routines does not make sense and results in an error message.

The option user_preamble can contain any number of Gnuplot commands, separated by semicolons, as a text string. Hence settings can be passed to Gnuplot, which cannot be controlled by plot options (e. g. setting the aspect ratio of a diagram).

The option dimensions declares the size of the graphic. The values for height and width do not apply to the diagram, but o the entire graphic (or scene), including labels and margin (default:

[600,500]).

Pixel graphics (png, jpg) are sized in pixels; the same holds true for the wx-routines (default: [500,300]).

Vector graphics (eps, jpg) are sized in 1/10 mm.

Gnuplot preamble, graphic size, color and number of initial points are declared as default values for all subsequent graphics.

Options for supression of tick marks are put into a list.

Generation of a Lissajous curve as a parametric curve

Drawing the Lissajous curve using the new default options and an additional list of options

(%i50)

set_draw_defaults(

 

 

user_preamble="set size ratio -1",

 

 

dimensions=[200,200],color=red,

 

 

nticks=200)$

 

(%i51)

notics:[xtics=false,ytics=false];

 

(%o51)

[x tics = f alse, y tics = f alse]

 

(%i52)

lissa:parametric(sin(3*t),sin(4*t),t,0,2*%pi);

 

(%o52)

parametric (sin (3 t) , sin (4 t) , t, 0, 2 π)

 

(%i53)

wxdraw2d(lissa,notics)$

(%t53)

Resetting all default values

(%i54)

set_draw_defaults();

 

(%o54)

[]

The option color and fill_color assign colors to all lines (outlines) and filled shapes, respectively; colors can be declared in hexadecimal form (#rrggbb) or by name according to the table below.

xrange, yrange and zrange are the displayed ranges in the respective coordinates in the form [min,max]. Their default values are false, in that case the displayed range will be calculated

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

24

automatically. Setting the logx, logy and logz to true causes logarithmic scale of the respectice axes.

grid, xtics, ytics and ztics control the display of grid lines and tick marks on the axes. grid=true causes grid lines to be drawn at the tick marks. The value of xtics, ytics and zticks can be false (no ticks), true (tick marcs calculated automatically) or a set of values, at which tick marks (and grid lines, if applicable) are drawn:

x(yz)tics={w1,w2,. . . }

Each value can also be a list having two elements: a text string, which will be plotted, and a coordinate value for the position of that text string:

x(yz)tics={["text1",w1],["text2",w2],. . . }

The option x(yz)tics_rotate=true causes a rotation of the text strings by 90 degree.

title, xlabel, ylabel, zlabel and key produce labels for the axes and the entire diagram.

 

white

 

light-green

 

light-pink

 

black

 

dark-green

 

dark-pink

 

 

 

 

gray0

 

spring-green

 

coral

 

 

 

 

gray10

 

forest-green

 

light-coral

 

 

 

 

gray20

 

sea-green

 

orange-red

 

 

 

 

gray30

 

blue

 

salmon

 

 

 

 

gray40

 

light-blue

 

light-salmon

 

 

 

 

gray50

 

dark-blue

 

dark-salmon

 

 

 

 

gray60

 

midnight-blue

 

aquamarine

 

 

 

 

gray70

 

navy

 

khaki

 

 

 

 

gray80

 

medium-blue

 

dark-khaki

 

 

 

 

gray90

 

royalblue

 

goldenrod

 

 

 

 

gray100

 

skyblue

 

light-goldenrod

 

 

 

 

gray

 

cyan

 

dark-goldenrod

 

 

 

 

light-gray

 

light-cyan

 

gold

 

 

 

 

dark-gray

 

dark-cyan

 

beige

 

 

 

 

red

 

magenta

 

brown

 

 

 

 

light-red

 

light-magenta

 

orange

 

 

 

 

dark-red

 

dark-magenta

 

dark-orange

 

 

 

 

yellow

 

turquoise

 

violet

 

 

 

 

light-yellow

 

light-turquoise

 

dark-violet

 

 

 

 

dark-yellow

 

dark-turquoise

 

plum

 

 

 

 

green

 

pink

 

purple

 

 

 

Farbnamen f"ur das Gnuplot-Interface Draw

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

25

Set of values for scale ticks along the y-axis and horizontal grid lines

Values for scale ticks along the x-axis and vertical grid lines as lists, each containing a text string and the x-coordinate

Sine curve with gridlines and tick marks

(%i55) yt:setify(create_list(signum(n) *sqrt(abs(n)),n,[-4,-3,-1,0,1,3,4])/2);

pp

 

 

1

 

1

 

 

3

 

3

 

 

 

 

 

 

 

(%o55)

−1, −

 

, 0,

 

 

, 1, −

 

 

 

,

 

 

 

 

 

 

 

 

 

 

2

2

2

 

2

 

 

 

 

 

 

 

 

 

(%i56)

xt:setify(makelist(

 

 

 

 

 

 

 

 

 

[string(30*n),30*n*%pi/180],n,0,12));

 

 

 

 

 

 

 

 

 

 

2 π

 

 

 

 

 

5 π

 

 

 

 

7 π

(%o56)

{[0, 0], [120,

 

], [150,

 

 

], [180, π], [210,

 

],

3

6

6

4 π

3 π

 

 

π

 

 

 

 

5 π

11 π

[240,

 

 

], [270,

 

], [30,

 

], [300,

 

 

], [330,

 

],

 

3

 

2

6

 

3

6

 

 

 

 

 

π

 

 

 

 

π

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[360, 2 π], [60, 3 ], [90, 2 ]}

(%i57) wxdraw2d(yrange=[-1.5,1.5],xtics=xt, ytics=yt,grid=true,color=red, explicit(sin(x),x,0,2*%pi), xlabel="phi (Grad)",ylabel="sin(phi)")$

(%t57)

Point plots (graphic object points) accept the option point_type with an integer value between −1 and 16 or a name according to the table below:

-1

$none

4

square

9

filled_up_triangle

0

dot

5

filled_square

10

down_triangle

1

plus

6

circle

11

filled_down_triangle

2

multiply

7

filled_circle

12

diamant

3

asterisk

8

up_triangle

13

filled_diamant

Possible values of the option point_type

Declaring points along a sine curve as a graphic object

(%i58) sine:points(float(map(lambda([u], [u,sin(u)]),makelist(u,u,-6,6)/2)));

(%o58) points([[−3.0, −0.141], [−2.5, −0.598], [−2.0, −0.909], [−1.5, −0.997], [−1.0, −0.841], [−0.5, −0.479], [0.0, 0.0], [0.5, 0.479], [1.0, 0.841], [1.5, 0.997], [2.0, 0.909], [2.5, 0.598], [3.0, 0.141]])

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

26

Declaring points along a straight line as a graphic object

Sine function and two point plots: Points along the sine function, as well as points along a straight line, connected by line segments.

(%i59) line:points(float(makelist([k,-k/4],k,-3,3)));

(%o59) points([[−3.0, 0.75], [−2.0, 0.5], [−1.0, 0.25], [0.0, 0.0], [1.0, −0.25], [2.0, −0.5], [3.0, −0.75]])

(%i60) wxdraw2d(color=blue,line_width=2, explicit(sin(x),x,-%pi,%pi), color=red,point_size=2,point_type=7, sine,points_joined=true,point_type=4, color=green,line)$

(%t60)

4.5 Options for Labels and Vectors

label_alignment=value Alignment of the label; possible values: center (default), left, right

label_orientation=value Orientation of the label; possible values: horizontal (default), vertical

head_length=len Length of the arrowheads of vectors in units of the x-axis (default: 2)

head_angle=winkel Angle between arrow heads and segment in degrees (default: 45)

head_type=typ Type of the arrow head of vectors; possible values: filled (default), empty, nofilled

head_both=true/false Decides, whether vectors are plotted with two arrow heads

Options for labels and vectors

Three text strings

Assigning long option names to short variable names unburdens subsequent writing.

(%i61) [l1,l2,l3]:["left aligned label", "centered label","rigt aligned label"]$

(%i62) [la,hs,ha,hl]:[label_alignment, head_size,head_angle,head_length]$

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

27

Vectors and variously aligned texts (%i63) wxdraw2d(xrange=[-1,1],yrange=[-6,5], yaxis=true,line_width=3,grid=true,la=left, label([l1,0,4]),la=center,label([l2,0,2]), la=right,label([l3,0,0]),ha=15,hl=0.2, color=red,vector([-0.5,-2],[0.5,0]), hl=0.3,color=blue,vector([-0.5,-4],[1,0]))$

(%t63)

4.6 Options for 2d-Graphics

axis_bottom=true/false The bottom axis is shown, if true (default).

axis_top=true/false The top axis is shown, if true (default).

axis_left=true/false The left axis is shown, if true (default).

axis_right=true/false The right axis is shown, if true (default).

filled_func=true/false The area between the plotted function and bottom axis is filled, if true.

filled_func=f The area between the plotted function and the function f is filled, if true.

transparent=true/false Polygons are colored according to the option fill_color, if true.

border=true/false Borders of polygons are painted, if true.

Options for 2d-graphics

List of options to supress axes and scale ticks

(%i64) noframe:[axis_left=false,axis_right=false, axis_top=false,axis_bottom=false, xtics=false,ytics=false]$

Wilhelm Haager: Graphics with MAXIMA

4 Graphic Interface Draw

28

Drawing various shapes with various

(%i65) wxdraw2d(noframe,line_width=2,

options

fill_color=dark-khaki,

 

color=forest-green,rechteck,

 

border=false,fill_color=orange,ell)$

(%t65)

Filling functions with colors

(%i66) wxdraw2d(line_width=3,filled_func=true,

 

color=black,explicit(sin(x),x,0,2*%pi),

 

fill_color=blue,explicit(cos(x),x,0,2*%pi),

 

filled_func=0.5*sin(3*x),fill_color=orange,

 

explicit( -0.5*sin(3*x),x,0,2*%pi))$

(%t66)

Wilhelm Haager: Graphics with MAXIMA

Соседние файлы в папке DOC