Featured image of post Wie man Graphen mit Python und matplotlib zeichnet 【Google Colab kompatibel】

Wie man Graphen mit Python und matplotlib zeichnet 【Google Colab kompatibel】

Erklärt für Anfänger die Schritte zum einfachen Zeichnen und Anzeigen von Sinus- und Kosinus-Graphen mit der matplotlib.pyplot-Bibliothek von Python unter Verwendung von Google Colaboratory. Kann sofort und ohne Einrichtung einer Umgebung ausprobiert werden.

img_1.png

Was Sie brauchen

  • Google-Konto

Schritte

  1. Gehen Sie auf https://colab.research.google.com/
  2. Wählen Sie “Datei” -> “Neues Notizbuch”
  3. Fügen Sie den folgenden Code ein und führen Sie ihn aus
1
2
3
4
5
6
7
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2*np.pi, 500)
plt.plot(x, np.sin(x), label="sin curve")
plt.plot(x, np.cos(x), label="cos curve")
plt.legend() # Legende anzeigen
plt.show()

Ausführungsergebnis

img.png

Referenzen

comments powered by Disqus
Erstellt mit Hugo
Theme Stack gestaltet von Jimmy