Annotations जोड़ना
अब तक कवर किए गए हर सुधार को आप साथ में जोड़ सकते हैं. अगले अभ्यास में, आप अपने distribution plot पर annotations जोड़ेंगे ताकि ऐसी रेखाएँ शामिल हों जो औसत और माध्यिका किराया कीमतें दिखाएँ.
इस उदाहरण के लिए, पैलेट को sns.set_palette() का उपयोग करके bright में बदला गया है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Data Visualization with Seaborn
अभ्यास निर्देश
- एक figure और axes बनाएँ.
fmr_1कॉलम का distribution प्लॉट करें.- पहले से परिभाषित
medianऔरmeanमानों के लिएaxvlineका उपयोग करके एक-एक वर्टिकल लाइन जोड़ें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create a figure and axes. Then plot the data
fig, ax = plt.subplots()
sns.histplot(df['fmr_1'], ax=ax)
# Customize the labels and limits
ax.set(____="1 Bedroom Fair Market Rent", xlim=(100,1500), title="US Rent")
# Add vertical lines for the median and mean
ax.axvline(x=____, color='m', label='Median', linestyle='--', linewidth=2)
ax.axvline(x=____, color='b', label='Mean', linestyle='-', linewidth=2)
# Show the legend and plot the data
ax.____()
plt.show()