Commit 3f746eb1 authored by Hafiz Emin Kosar's avatar Hafiz Emin Kosar
Browse files

- figsizes can be changed in notebooks now

parent cc8ecfbc
......@@ -43,11 +43,12 @@
mit $Q$ Nullstellen $p_{\mathrm{N},q}$ und $R$ Polstellen $p_{\mathrm{P},r}$ betrachtet und verändert werden. Dargestellt ist ein Pol-/Nullstellendiagramm, sowie die zugehörige Impulsantwort und Übertragungsfunktion.
%% Cell type:code id: tags:
``` python
pzp = pzPlot()
fig = plt.figure(figsize=(10, 10/16*9))
pzp = pzPlot(fig)
```
%% Cell type:markdown id: tags:
### Anleitung
......
......@@ -36,12 +36,13 @@
n = np.linspace(-5, 5, 11)
pp = np.array([0.5, 2]); pz = np.array([0])
roc = np.array([0.5, 2])
#roc = np.array([-b, np.inf])
fig, axs = plt.subplots(1, 2)
fig, axs = plt.subplots(1, 2, figsize=(8, 8/ient_fig_aspect))
ax = axs[0]
ax.set_aspect('equal', adjustable='datalim')
zroc = ient_plot_zroc(ax, roc)
ax.plot(np.real(pp), np.imag(pp), **ient_style_poles); ax.plot(np.real(pp), -np.imag(pp), **ient_style_poles)
ax.plot(np.real(pz), np.imag(pz), **ient_style_zeros); ax.plot(np.real(pz), -np.imag(pz), **ient_style_zeros)
ax.set_xlabel(r'$\rightarrow \mathrm{Re}$'); ax.set_ylabel(r'$\uparrow \mathrm{Im}$');
ax.set_xlim(np.min(n), np.max(n)); ax.set_ylim(ax.get_xlim()); ient_grid(ax); ient_axis(ax)
......@@ -59,11 +60,12 @@
## Interaktive Demo
%% Cell type:code id: tags:
``` python
zp = zPlot()
fig = plt.figure(figsize=(10, 10/16*9))
zp = zPlot(fig)
```
%% Cell type:markdown id: tags:
### Anleitung
......
......@@ -32,7 +32,7 @@ class pzPlot():
fig = None
ax = None
handles = {'ph': None, 'axh': None, 'pH': None, 'axH': None}
filter_types = {'Manuell' : 'man', 'Butterworth' : 'butr', 'Sprungfunktion' : 'unit',
filter_types = {'Manuell' : 'man', 'Butterworth' : 'butr', 'Sprungfunktion' : 'unit',
'Sinus' : 'sin', 'Cosinus' : 'cos'}
mode = 'p'
mode_types = {'Polstelle': 'p', 'Nullstelle': 'z'}
......@@ -44,7 +44,7 @@ class pzPlot():
P = 1 # no of poles for butterworth filter
def __init__(self, pp=np.array([0]), pz=np.array([]), ord_p=np.array([1]), ord_z=np.array([])):
def __init__(self, fig, pp=np.array([0]), pz=np.array([]), ord_p=np.array([1]), ord_z=np.array([])):
self.H0 = 1
self.filter = 'unit'
......@@ -57,7 +57,7 @@ class pzPlot():
self.t = np.linspace(-6, 6, num=self.length)
self.f = np.linspace(-6, 6, num=self.length)
self.open_figure()
self.open_figure(fig)
# Poles
......@@ -83,9 +83,8 @@ class pzPlot():
self.update_roc(1)
def open_figure(self):
def open_figure(self, fig):
fig = plt.figure(figsize=(8, 8))
gs = gridspec.GridSpec(2, 2)
# First axis for plotting s and h
......@@ -100,6 +99,7 @@ class pzPlot():
self.fig = fig
self.ax = ax
self.ax.set_title('Pol- /Nullstellen Diagramm', fontsize='12')
self.ax.set_aspect('equal', adjustable='datalim')
def onclick(event):
if self.action == 'add' and event.key == 'shift':
......@@ -126,7 +126,7 @@ class pzPlot():
self.handles['axh'].set_title('Impulsantwort', fontsize='12')
self.handles['axh'].set_xlabel(r'$\rightarrow t$')
self.handles['axh'].set_ylabel(r'$\uparrow h(t)$')
self.pbzErrortxt = self.handles['axh'].text(-7, 3.25,
self.pbzErrortxt = self.handles['axh'].text(-.6, .0125,
'Zählergrad größer als Nennergrad. \nKeine Partialbruchzerlegung möglich!',
fontsize=12, color='rot', visible=False, bbox=ient_wbbox)
self.handles['lineh'], = self.handles['axh'].plot(self.t, self.t)
......@@ -145,7 +145,7 @@ class pzPlot():
self.fig.canvas.layout.height = '600px'
fig.tight_layout();
#plt.subplots_adjust(wspace=.25)
# Widgets
self.w_filter_type = interactive(self.update_filter,filtr=widgets.Dropdown(options=list(self.filter_types.keys()), value="Sprungfunktion", description='Filter'))
self.w_action_type = interactive(self.update_action,action=widgets.Dropdown(options=list(self.action_types.keys()),value="Hinzufügen", description='Modus', disabled=True))
......@@ -360,9 +360,9 @@ class pzPlot():
def update_widgets(filtr):
if filtr == "Manuell":
b = False
else:
else:
b = True
self.w_action_type.children[0].disabled = b
self.w_point_type.children[0].disabled = b
......
......@@ -42,7 +42,7 @@ class zPlot():
H = None
Hlog = None
def __init__(self, pp=np.array([0]), pz=np.array([]), ord_p=np.array([1]), ord_z=np.array([])):
def __init__(self, fig, pp=np.array([0]), pz=np.array([]), ord_p=np.array([1]), ord_z=np.array([])):
self.H0 = 1
#self.filter = 'unit'
......@@ -53,7 +53,7 @@ class zPlot():
self.n = np.linspace(-15, 15, num=self.length)
self.f = np.linspace(-15, 15, num=1024)
self.open_figure()
self.open_figure(fig)
# Poles
return
......@@ -78,9 +78,8 @@ class zPlot():
self.update_roc(1)
def open_figure(self):
def open_figure(self, fig):
fig = plt.figure(figsize=(8, 8))
gs = gridspec.GridSpec(2, 2)
# First axis for plotting s and h
......@@ -138,9 +137,7 @@ class zPlot():
# initial dirac plot
(self.cp, self.cn) = ient_plot_dirac(self.handles['axh'], [-1, 1], [-1, 1], 'rwth')
ient_dirac_set_data((self.cp, self.cn), [], [])
self.fig.canvas.layout.height = '600px'
fig.tight_layout();
# plt.subplots_adjust(wspace=.25)
# Widgets
self.w_filter_type = interactive(self.update_filter,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment