matplotlib में Subfigures
कभी-कभी आप कई subplots को एक ही figure में जोड़ना चाहते हैं.
आप यह plot.subplots() फंक्शन का उपयोग करके एक साथ figure और axes बनाकर कर सकते हैं.
यह फंक्शन figure और axes ऑब्जेक्ट्स लौटाता है:
import matplotlib.pyplot as plt
# Create a figure and axes
fig, (ax1, ax2) = plt.subplots(number_of_rows, number_of_columns)
अब आप इन axes ऑब्जेक्ट्स का उपयोग करके प्लॉट बना सकते हैं:
# Use the axes to plot visualizations
ax1.hist(df['column_1'])
ax2.hist(df['column_2'])
plt.show()
यह अभ्यास पाठ्यक्रम का हिस्सा है
R उपयोगकर्ताओं के लिए Python
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
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()