matplotlib'de alt şekiller (subfigure)
Bazen birden fazla alt grafiği tek bir şekilde birleştirmek istersin.
Bunu, plot.subplots() fonksiyonunu kullanarak aynı anda bir figure ve axes oluşturarak yapabilirsin.
Bu fonksiyon figure ve axes nesnelerini döndürür:
import matplotlib.pyplot as plt
# Bir figure ve axes oluştur
fig, (ax1, ax2) = plt.subplots(number_of_rows, number_of_columns)
Artık bu axes nesnelerini kullanarak grafikler üretebilirsin:
# Görselleştirmeleri çizmek için axes'i kullan
ax1.hist(df['column_1'])
ax2.hist(df['column_2'])
plt.show()
Bu egzersiz
R Kullanıcıları için Python
kursunun bir parçasıdırUygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
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()