साझा y अक्ष के साथ small multiples
Small multiples बनाते समय, अक्सर बेहतर होता है कि सभी प्लॉट्स y-axis पर एक ही स्केल में दिखें. इसे sharey की-वर्ड को True सेट करके कॉन्फ़िगर किया जा सकता है.
इस अभ्यास में, आप दो Axes ऑब्जेक्ट्स वाली एक Figure बनाएँगे जो अपना y-axis साझा करते हैं. पहले की तरह, डेटा seattle_weather और austin_weather DataFrames में दिया गया है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय
अभ्यास निर्देश
- ऐसी Figure बनाएँ जिसमें दो Axes ऑब्जेक्ट्स की array हो और वे अपना y-axis रेंज साझा करें.
- ऊपर वाले Axes में Seattle के
"MLY-PRCP-NORMAL"को सॉलिड नीली लाइन में प्लॉट करें. - ऊपर वाले Axes में ही Seattle के
"MLY-PRCP-25PCTL"और"MLY-PRCP-75PCTL"को डैश्ड नीली लाइनों में जोड़ें. - नीचे वाले Axes में Austin के
"MLY-PRCP-NORMAL"को सॉलिड लाल लाइन में प्लॉट करें और"MLY-PRCP-25PCTL"तथा"MLY-PRCP-75PCTL"को डैश्ड लाल लाइनों में जोड़ें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create a figure and an array of axes: 2 rows, 1 column with shared y axis
fig, ax = plt.subplots(2, 1, sharey=True)
# Plot Seattle precipitation data in the top axes
____.plot(____, ____, color = ____)
____.plot(____, ____, color = ____, linestyle = ____)
____.plot(____, ____, color = ____, linestyle = ____)
# Plot Austin precipitation data in the bottom axes
____.plot(____, ____, color = ____)
____.plot(____, ____, color = ____, linestyle = ____)
____.plot(____, ____, color = ____, linestyle = ____)
plt.show()