Programme für Diagrammtypen: Säule, gestapelte Säulen
Linien, gestapelte Balken, Torte
This commit is contained in:
45
teil23/sinus_parabel_graph.py
Executable file
45
teil23/sinus_parabel_graph.py
Executable file
@@ -0,0 +1,45 @@
|
||||
#! ./bin/python
|
||||
# encoding:utf-8
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def plot_normal_parabel():
|
||||
# Erzeuge Datenpunkte für x-Werte von -10 bis 10
|
||||
x = np.linspace(-3, 3, 100)
|
||||
|
||||
# Berechne die y-Werte für die Normalparabel
|
||||
y = x**2
|
||||
|
||||
# Erstelle das Diagramm
|
||||
plt.plot(x, y, label='Normalparabel: $y=x^2$')
|
||||
|
||||
# Beschriftungen und Titel hinzufügen
|
||||
plt.xlabel('x-Achse')
|
||||
plt.ylabel('y-Achse')
|
||||
plt.title('Normalparabel')
|
||||
|
||||
# Legende hinzufügen
|
||||
plt.legend()
|
||||
|
||||
|
||||
def plot_sinus_function():
|
||||
# Erzeuge Datenpunkte für x-Werte von -2π bis 2π
|
||||
x = np.linspace(-2 * np.pi, 2 * np.pi, 100)
|
||||
|
||||
# Berechne die y-Werte für die Sinusfunktion
|
||||
y = np.sin(x)
|
||||
|
||||
# Erstelle das Diagramm für die Sinusfunktion
|
||||
plt.plot(x, y, label='Sinusfunktion: $y = \sin(x)$', color='blue')
|
||||
|
||||
# Legende hinzufügen
|
||||
plt.legend()
|
||||
|
||||
|
||||
# Funktion aufrufen, um die Normalparabel zu zeichnen
|
||||
plot_normal_parabel()
|
||||
plot_sinus_function()
|
||||
|
||||
# Diagramm anzeigen
|
||||
plt.grid(True)
|
||||
plt.show()
|
Reference in New Issue
Block a user