Zurück zum Inhaltsverzeichnis

Kapitel 19

Schaubilder zeichnen

> with(plots):

Verschiedene Varianten für Funktionen und Terme

Funktion

> plot(sin);

[Maple Plot]

> plot(sin, -10..10);

[Maple Plot]

Term

> plot(sin(x), x=-10..10);

[Maple Plot]

> plot( {sin(x), x^2/20}, x=0..2*Pi);

[Maple Plot]

> plot( {seq(sin(n*x)/n, n=1..5)}, x=0..Pi);

[Maple Plot]

>

Sonderfall Singularität

> plot( x/(x^2-1), x=-2..3,numpoints=500);

[Maple Plot]

Maple verwendet einen adaptiven Algorithmus, der um so genauer rechnet, je mehr sich die Funktion ändert.

>

Dieser Algorithmus lässt sich so abschalten:

> plot( x/(x^2-1), x=-2.1..2.95, adaptive=false);

[Maple Plot]

>

So vermeidet man die Singularitäten mit Sicherheit:

> plot( x/(x^2-1), x=-2.1..2.95, adaptive=false,sample=[-2,-1/2,0,1/2,2]);

[Maple Plot]

>

Die gängige Methode, eine vernünftige Darstellung trotz Singularitäten zu bekommen, ist die Einschränkung des vertikalen Bereichs:

> plot( x/(x^2-1), x=-2..3, -10..10);

[Maple Plot]

>

Mit Unterdrückung der 'Polgeraden':

> plot( x/(x^2-1), x=-2..3, -10..10,discont=true, color=black);

[Maple Plot]

>

Unendliche Plotbereiche

> plot( {x,1+x^2,2+x^x}, x=0..infinity, 0..infinity);

[Maple Plot]

>

Auflösung gefragt:

> plot( sin(x^3), x=1..5,numpoints=1500);

[Maple Plot]

>

In Plots können nur Zahlen verarbeitet werden:

> plot( a*x^2+b*x+c, x=0..3);

Plotting error, empty plot

>

> plot( subs(a=1, b=-2, c=2, a*x^2+b*x+c), x=0..3);

[Maple Plot]

>

Fallunterscheidungen müssen zur rechten Zeit getroffen werden:

> f:=proc(x) if x>0 then sin(x) else x fi end:

> plot( f(x), x=-2..5);

Error, (in f) cannot evaluate boolean: -x < 0

> plot( 'f(x)', x=-2..5);

[Maple Plot]

>

Imaginäre Größen bleiben unsichtbar:

> plot( sin(I*x), x=-1..1);

Plotting error, empty plot

> plot( { Re(sin(1+I*x)), Im(sin(1+I*x)) }, x=-2..2);

[Maple Plot]

>

>

Parametrische Plots

Vor allem für Physiker interessant. Denn wo kommt in der Realität eine Kurve vor, die sich mit einer eindeutigen Funktion im x-y-Koordinatensystem beschreiben lässt?

> restart:

> plot( [ t*cos(t), t*sin(t), t=0..6*Pi], scaling=constrained );

[Maple Plot]

>

Alternative:

> plot(x,x=0..6*Pi,coords=polar, scaling=constrained);

[Maple Plot]

>

> plot( [ sin(phi)*sin(3*phi), phi,phi=0..2*Pi]);

[Maple Plot]

>

>

> plot( [[ sin(phi)*sin(3*phi)+phi, -sin(phi)*sin(3*phi)+phi,phi=0..2*Pi],[x,x,x=0..2*Pi]],scaling=constrained,color=black,numpoints=500);

[Maple Plot]

>

>

Phasendiagramme

>

Zur Übung

> x:=t->t^2;

x := proc (t) options operator, arrow; t^2 end proc...

> y:=t->sin(t);

y := sin

> plot([x(t),t,t=0..2]);

[Maple Plot]

> plot([t,x(t),t=0..2]);

[Maple Plot]

>

> plot([y(t),x(t),t=0..2]);

[Maple Plot]

Experimentieren Sie mit eigenen Belegungen für x und y!

>

>

In anderen Koordinaten:

> plot( [ sin(phi)*sin(3*phi), phi,phi=0..2*Pi],coords=polar );

[Maple Plot]

>

> plot( [[ sin(phi)*sin(3*phi)+phi, -sin(phi)*sin(3*phi)+phi,phi=0..2*Pi],[x,x,x=0..2*Pi]],scaling=constrained, coords=polar,numpoints=500);

[Maple Plot]

>

>

Koordinatensysteme (2D)

Es gibt 15 Koordinatensysteme (2D)

>

>

> co:= [bipolar, cardioid, cartesian, cassinian, elliptic, hyperbolic, invcassinian, invelliptic, logarithmic, logcosh, maxwell, parabolic, polar, rose, tangent];

co := [bipolar, cardioid, cartesian, cassinian, ell...
co := [bipolar, cardioid, cartesian, cassinian, ell...

>

So sieht die 1 in den verschiedenen Koordinatensystemen aus. Experimentieren Sie mit IHRER Funktion:

> with(plots):

> for c in co do
plot(1,x=-Pi..Pi, numpoints=500, coords=c, title=c, scaling=constrained) od;

>

>

> for c in co do
p[c]:=plot(1,x=-Pi..Pi, numpoints=500, coords=c, title=c) od:

>

> #p[elliptic];

>

All together now:

> plots[display]([seq(p[c],c=co)]);

[Maple Plot]

>

>

> #?plotsetup

> #plotsetup(help);

Die nächsten Befehle erzeugen 15 neue Fenster

> plotsetup(window);

> for c in co do
coordplot(c,[-4..4,-Pi..Pi],title=c,scaling=constrained) od;

Jetzt wieder inline.

> plotsetup(default);

>

Für eine angepasste Darstellung ist oft view[..] erforderlich

> ks:=coordplot(polar,[0..3,0..2*Pi],grid=[10,20],scaling=constrained,view=[-3..3,-3..3]):ks;

> spir:=plot(0.05*x,x=0..20*Pi,coords=polar,thickness=2,color=black,numpoints=500,scaling=constrained):spir;

> display(ks,spir);

>

>

>

>

>

>

Implizit gegebene Funktionen zeichnen

Wenn man keine explizite Formulierung kennt, oder wenn sie zu kompliziert wird, können Zusammenhänge mit implicitplot gezeigt werden.

> with(plots):

Warning, the name changecoords has been redefined

> implicitplot( x^2-x=y^3-3*y, x=-3..3, y=-2..3);

[Maple Plot]

Oder:

> #implicitplot( (x,y)-> x^2-x-y^3+3*y, -3..3, -2..3);

>

Das wäre nicht so angenehm:

> solve(x^2-x=y^3-3*y,y);

>

Implicitplot arbeitet numerisch:

> implicitplot( sin(x*y), x=-3..5, y=0..10);

[Maple Plot]

Und benötigt manchmal eine hörere Auflösung

> implicitplot( sin(x*y), x=-3..5, y=0..10, grid=[80,80]);

[Maple Plot]

>

>

>

Punkte und Linien

> plot( [[1,1], [2,2], [3,2], [4,1]] );

[Maple Plot]

> plot(sin(x),x=0..2*Pi, style=point, symbolsize=20,color=black);

[Maple Plot]

> data:=seq( [rand(100)(),rand(100)()], n=1..100):

> plot( [data], style=point );

[Maple Plot]

>

Alternativen

> plots[listplot]( [data], style=point );

[Maple Plot]

> plots[pointplot]( [data] );

[Maple Plot]

>

Überlagerung von Grafiken

Jeder plot-Befehl erzeugt eine 'Plotstruktur'. Mit display können diese Strukturen erneut angezeigt werden - modifiziert oder zusammen mit anderen.

>

> restart:with(plots):

Warning, the name changecoords has been redefined

> f:=x->x+sin(x); df:=D(f);

f := proc (x) options operator, arrow; x+sin(x) end...

df := proc (x) options operator, arrow; 1+cos(x) en...

> x0:=solve(df(x)=1);

x0 := 1/2*Pi

>

Gibt man einem Plot einen Namen, so sollte man den Befehl mit einem Doppelpunkt abschließen, weil sonst die Plotstruktur nicht gezeichnet, sondern ausgedruckt wird.

> p1:=plot(f(x), x=0..4,color=black):

> p2:=plot( [[x0-0.5, f(x0)-0.5*df(x0)], [x0+0.5,f(x0)+0.5*df(x0)]] ):

> display( [p1, p2], scaling=constrained);

[Maple Plot]

>

>

> x0:=solve(df(x)=s,x);

x0 := arccos(-1+s)

> display(seq({p1,plot( [[x0-0.5, f(x0)-0.5*df(x0)], [x0+0.5,f(x0)+0.5*df(x0)]] )},s=[2,1,1/2,1/3,1/4]),view=[-1..4,-1..4]);

[Maple Plot]

> display(seq(display(p1,plot( [[x0-0.5, f(x0)-0.5*df(x0)], [x0+0.5,f(x0)+0.5*df(x0)]],thickness=2 )),s=[2,1,1/2,1/3,1/4]),view=[-1..4,-1..4], insequence=true);

[Maple Plot]

>

>

Ein Beispiel aus der Statistik

> datax:=[seq(i*0.3,i=1..20)]:

> datay:=map(sin, datax):

> data:=zip( (x,y)->[x,y], datax, datay):

>

> with(stats):

> f:=rhs(fit[leastsquare[[x,y],y=d*x^3+a*x^2+b*x+c]]([datax,datay]));

f := .9946921269e-1*x^3-.9378758828*x^2+2.065951791...

>

> p1:=plot( data, style=point):

> p2:=plot( f, x=0..6):

> display( [p1,p2] );

[Maple Plot]

>

>

Mehrere Bilder in einem Array

> restart: with(plots):

Warning, the name changecoords has been redefined

> p1:=plot(sin(x),x=-Pi..Pi,-1..1,color=black):
p2:=plot(cos(x),x=-Pi..Pi,color=black):
p3:=plot(sinh(x),x=-Pi..Pi,color=black):
p4:=plot(cosh(x),x=-Pi..Pi,color=black):

> display(array(1..2,1..2,[[p1,p2],[p3,p4]]),tickmarks=[2,3] );

[Maple Plot]

>

>

Beschriftung von Grafik

> plot( sin(x), x=0..2*Pi, title=`Sinusfunktion`,labels=[`x-Achse`, `y-Achse`],color=black);

[Maple Plot]

> p1:=plot(sin(x), x=0..2*Pi):

> p2:=textplot([3*Pi/2, 0.5,`sin(x)`] ):

> display( [p1, p2] );

[Maple Plot]

>

Für die Ausgabe in Postscript

> display( [p1, p2], font=[TIMES, ITALIC, 50],axesfont=[TIMES,ROMAN,30]);

[Maple Plot]

>

Darstellungsoptionen

Linienstärken

> plot( [seq(sin(x+n*Pi/8),n=1..3)], x=0..2*Pi, thickness=[1,2,5], color=black);

[Maple Plot]

>

> plot( [seq(sin(x+n*Pi/8),n=1..5)], x=0..2*Pi, linestyle=[1,2,3,4,5], color=black);

[Maple Plot]

>

> plot( [seq(sin(x+n*Pi/8),n=1..5)], x=0..2*Pi, linestyle=[1,2,3,4,5], color=[red,green,blue,yellow,black]);

[Maple Plot]

>

>

Legende mit Kontextmenü erzeugt

> plot( [seq(sin(x+n*Pi/8),n=1..5)], x=0..2*Pi, linestyle=[1,2,3,4,5], color=[red,green,blue,yellow,black]);

[Maple Plot]

>

Legende im Plotbefehl

> plot( [seq(sin(x+n*Pi/8),n=1..5)], x=0..2*Pi, linestyle=[1,2,3,4,5], color=[red,green,blue,yellow,black],legend=[a,b,c,d,e]);

[Maple Plot]

>

>

Style, Symbol und Symbolgröße

> plot(x,x,style=point,symbolsize=20);

[Maple Plot]

>

Das Symbol Point ist wirklich ein Punkt

> plot( [seq(sin(x+n*Pi/4),n=1..5)], x=0..2*Pi, style=point,
symbol=[BOX, CROSS, CIRCLE, DIAMOND, POINT], color=black, numpoints=100,symbolsize=[10,12,14,16,20]);

[Maple Plot]

>

Gefüllt

> plot([cos(x),sin(x)],x=-2*Pi..2*Pi,filled=true,color=[grey,yellow]);

[Maple Plot]

>

>

Maßstab

> display(plot(x,x=-1..1),implicitplot( x^2+y^2=1, x=-1..1, y=-1..1));

[Maple Plot]

>

> display(%,scaling=constrained);

[Maple Plot]

>

Die Option view

> implicitplot( x^2+y^2=1, x=-1..1, y=-1..1,view=[-1..1,-2..2],color=black);

[Maple Plot]

> implicitplot( x^2+y^2=1, x=-2..2, y=-1..1, view=[-2..2,-1..1], scaling=constrained,color=black,tickmarks=[2,2]);

[Maple Plot]

Achsen

> plot( [ sin(3*t), cos(5*t), t=0..2*Pi ], axes=boxed);

[Maple Plot]

> plot( [ sin(3*t), cos(5*t), t=0..2*Pi ], axes=frame);

[Maple Plot]

>

>

>

Zurück zum Inhaltsverzeichnis