Lektion 4

Graphik

In [34]:
import matplotlib.pyplot as plt
import sympy as sp
import numpy as np
In [35]:
%matplotlib notebook
#%matplotlib inline

Sympy Graphik

Einfache Graphen von Funktionen

In [36]:
x = sp.symbols('x')
f = sp.exp(-x)*sp.sin(2*x)
p1 = sp.plot(f,(x,-sp.pi,sp.pi),show=False)
p2 = sp.plot(5*sp.cos(x),(x,-sp.pi,sp.pi),show=False)
p1.extend(p2)
p1.legend=True
p1[1].line_color='red'
p1.show()
dir(p1)
Out[36]:
['__class__',
 '__delattr__',
 '__delitem__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_backend',
 '_series',
 'append',
 'aspect_ratio',
 'autoscale',
 'axis',
 'axis_center',
 'backend',
 'extend',
 'legend',
 'margin',
 'save',
 'show',
 'title',
 'xlabel',
 'xlim',
 'xscale',
 'ylabel',
 'ylim',
 'yscale']

Implizit gegebene Kurven

In [37]:
x,y,z =sp.symbols('x y z')
p3 = sp.plotting.plot_implicit(sp.Eq(x**2+y**2,1),(x,-1,1),(y,-1,1),line_color='red')
ax = p3._backend.ax
ax.set_aspect('equal')
In [38]:
sp.plotting.plot_implicit(sp.Le(x**2+y**3,1))
Out[38]:
<sympy.plotting.plot.Plot at 0x7f6be38df470>
In [39]:
t = sp.symbols('t')
p1 = sp.plotting.plot_parametric((sp.sin(t),sp.cos(t)),((t/2)**2,t),(t,-sp.pi,sp.pi))
ax = p1._backend.ax
ax.set_aspect('equal')

Sympy Graphik 3D

In [40]:
sp.plotting.plot3d(sp.exp(-x**2-y**2),(x,-2,2),(y,-2,2),surface_color='green');

Parametrische Kurven

In [41]:
sp.plotting.plot3d_parametric_line(sp.cos(x),sp.sin(x),x,(x,-10,10))
Out[41]:
<sympy.plotting.plot.Plot at 0x7f6be3bd1c50>

Parametrische Flaechen

In [42]:
sp.plotting.plot3d_parametric_surface(x,y,x**2+2*y**2,(x,-2,2),(y,-2,2))