Teilabbildungen in matplotlib
Manchmal willst du mehrere Teilplots in einer einzigen Abbildung kombinieren.
Das geht, indem du gleichzeitig eine Figure und Achsen mit der Funktion plot.subplots() erstellst.
Diese Funktion gibt das Figure- und das Axes-Objekt zurück:
import matplotlib.pyplot as plt
# Create a figure and axes
fig, (ax1, ax2) = plt.subplots(number_of_rows, number_of_columns)
Diese Axes-Objekte kannst du nun zum Erstellen von Plots verwenden:
# Use the axes to plot visualizations
ax1.hist(df['column_1'])
ax2.hist(df['column_2'])
plt.show()
Diese Übung ist Teil des Kurses
Python für R-Nutzer
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
import matplotlib.pyplot as plt
# Create a figure with 1 axes
fig, ax = plt.____(1, 1)
# Plot a scatter plot in the axes
____.scatter(tips____, tips____)
plt.show()