शुरू करेंमुफ़्त में शुरू करें

अतिरिक्त कस्टमाइज़ेशन

यदि आप स्क्रिप्ट को फिर से देखें, # Additional Customizations के नीचे, तो आप देखेंगे कि अब दो plt.text() फंक्शन हैं। ये प्लॉट में "India" और "China" टेक्स्ट जोड़ते हैं.

यह अभ्यास पाठ्यक्रम का हिस्सा है

इंटरमीडिएट Python

पाठ्यक्रम देखें

अभ्यास निर्देश

  • plt.text() कॉल्स के बाद plt.grid(True) जोड़ें ताकि प्लॉट पर gridlines ड्रॉ हों.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Scatter plot
plt.scatter(x = gdp_cap, y = life_exp, s = np.array(pop) * 2, c = col, alpha = 0.8)

# Previous customizations
plt.xscale('log') 
plt.xlabel('GDP per Capita [in USD]')
plt.ylabel('Life Expectancy [in years]')
plt.title('World Development in 2007')
plt.xticks([1000,10000,100000], ['1k','10k','100k'])

# Additional customizations
plt.text(1550, 71, 'India')
plt.text(5700, 80, 'China')

# Add grid() call


# Show the plot
plt.show()
कोड संपादित करें और चलाएँ