master > master: src - methoden funktionieren

This commit is contained in:
RD
2022-10-20 22:04:06 +02:00
parent 7b237246da
commit 96684d30a8
2 changed files with 59 additions and 24 deletions

View File

@@ -66,18 +66,24 @@ class Function(Generic[T1,T2]):
return Functions(self).draw();
class Functions:
name: str;
fcts: list[Function];
def __init__(self, *f: Function):
self.fcts = list(f);
self.name = r' \circ '.join([ fct.name[0] for fct in self.fcts ][::-1]);
def draw(self, show_labels: bool = True) -> Figure:
N = len(self.fcts);
obj = mplot.subplots(1, 1, constrained_layout=True);
fig: Figure = obj[0];
axs: Axes = obj[1];
axs.tick_params(axis='both', which='both', left=False, right=False, top=False, bottom=False, labelbottom=False, labelleft=False);
mplot.title('');
axs.tick_params(axis='both', which='both', labelbottom=False, labelleft=False);
mplot.title(f'Darstellung von ${self.name}$', fontdict={
'fontsize': 16,
'horizontalalignment': 'center',
'color': 'forestgreen',
});
mplot.xlabel('');
mplot.ylabel('');
mplot.margins(x=MARGIN, y=MARGIN);
@@ -127,7 +133,7 @@ class Functions:
for j, p in enumerate(p_codomain):
y = f.codomain[j];
marker = 'o' if (y in comp_range_next) else 'x';
marker = 'o' if (y in comp_range_next) else '.';
axs.scatter([p[0]], [p[1]], label='', color='black', marker=marker);
y_name = f.codomain[j];
if show_labels:
@@ -138,16 +144,16 @@ class Functions:
q = p_codomain[j];
x = f.domain[i];
if k == 0 or (x in comp_range):
axs.plot([p[0], q[0]], [p[1], q[1]], label='', color='g', linewidth=2);
axs.plot([p[0], q[0]], [p[1], q[1]], label='', color='black', linewidth=1);
else:
axs.plot([p[0], q[0]], [p[1], q[1]], label='', color='g', linestyle='--', linewidth=1);
axs.plot([p[0], q[0]], [p[1], q[1]], label='', color='red', linestyle='--', linewidth=1);
anchor = anchors[k];
fct_name, X_name, Y_name = f.name;
axs.annotate(text=f'{fct_name}', xy=anchor[0], ha='center', size=FONTSIZE_FCT);
axs.annotate(text=f'${fct_name}$', xy=anchor[0], ha='center', size=FONTSIZE_FCT);
if k == 0:
axs.annotate(text=f'{X_name}', xy=anchor[1], ha='center', size=FONTSIZE_FCT);
axs.annotate(text=f'{Y_name}', xy=anchor[2], ha='center', size=FONTSIZE_FCT);
axs.annotate(text=f'${X_name}$', xy=anchor[1], ha='center', size=FONTSIZE_FCT);
axs.annotate(text=f'${Y_name}$', xy=anchor[2], ha='center', size=FONTSIZE_FCT);
axs.add_patch(FancyArrowPatch(
anchor[3], anchor[4],
connectionstyle = 'arc3,rad=0.5',
@@ -176,8 +182,6 @@ def oval(
P[-1, :] = P[0, :];
return P;
def random_points(
nr_points: int,
scale: tuple[float, float] = (1., 1.),