-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeispiel_plots.py
33 lines (23 loc) · 897 Bytes
/
beispiel_plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""Erstellen einfacher Plots mit matplotlib.
Das grafische Darstellen von Daten ist einer der wichtigsten
Aufgabenbereiche der Datenverarbeitung. Wir verwenden zu diesem Zweck
matplotlib [0], eine plotting library, die sich als de facto Standard
für Visualisierungen aller Art etabliert hat.
[0] http://matplotlib.org/
"""
import matplotlib.pyplot as plt
import numpy as np
# Erstellen einer Datenreihe (Nebenrechnung)
x = np.linspace(0, 2 * np.pi, 20)
y = np.sin(x)
# Plot der Daten als Linie
fig, ax = plt.subplots()
ax.plot(x, y, color='r', linewidth=2)
ax.legend('Beispiel', loc='upper left')
# Plot der einzelnen Datenpunkte
fig, ax = plt.subplots()
ax.plot(x, y, linestyle='none', marker='x', markersize=10)
# Plots werden in Python im Hintergrund geöffnet und müssen aktiv in den
# Vordergrund geholt werden, wenn man sie betrachten möchte.
plt.show()