- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeispiel_subplot.py
More file actions
Latest commit
28 lines (20 loc) · 718 Bytes
/
Copy pathbeispiel_subplot.py
File metadata and controls
28 lines (20 loc) · 718 Bytes
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
# -*- coding: utf-8 -*-
"""Erstellen von Subplots mit matplotlib.
Um mehrere Plots in einer figure zu plotten, gibt es den Befehl
subplot(). Seine Anwendung soll hier an einem einfachen Beispiel
gezeigt werden.
"""
importmatplotlib.pyplotasplt
importnumpyasnp
# Erstellen eines x-Vektors (Nebenrechnung)
x=np.linspace(0, 10, 100)
# Erstellen einer figure mit zwei Plots nebeneinander.
# plt.sublots(Reihen, Spalten)
fig, axes=plt.subplots(1, 2)
# Die Variable axes ist ein Array, mit dessen Einträgen auf die
# einzelnen Subplots zugegriffen werden kann.
axes[0].plot(x, np.sin(x))
axes[0].set_title('Sinus')
axes[1].plot(x, np.cos(x))
axes[1].set_title('Cosinus')
plt.show() # Anzeigen des Plots