अपनी figures दूसरों से साझा करने के लिए तैयार करना

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

Ariel Rokem

Data Scientist

प्लॉट स्टाइल बदलना

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"])
ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"])
ax.set_xlabel("Time (months)")
ax.set_ylabel("Average temperature (Fahrenheit degrees)")
plt.show()

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

स्टाइल चुनना

plt.style.use("ggplot")

fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) ax.set_xlabel("Time (months)") ax.set_ylabel("Average temperature (Fahrenheit degrees)") plt.show()

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

वापस default पर

plt.style.use("default")
Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

उपलब्ध स्टाइल्स

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

"bmh" स्टाइल

plt.style.use("bmh")

fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) ax.set_xlabel("Time (months)") ax.set_ylabel("Average temperature (Fahrenheit degrees)") plt.show()

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

Seaborn स्टाइल्स

plt.style.use("seaborn-colorblind")

fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) ax.set_xlabel("Time (months)") ax.set_ylabel("Average temperature (Fahrenheit degrees)") plt.show()

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

प्लॉटिंग स्टाइल चुनने के दिशानिर्देश

  • डार्क बैकग्राउंड अक्सर कम दिखता है
  • अगर रंग अहम है, तो colorblind-friendly विकल्प लें
    • "seaborn-colorblind" या "tableau-colorblind10"
  • अगर figure प्रिंट होने की है, तो कम इंक उपयोग करें
  • अगर ब्लैक-एंड-व्हाइट में प्रिंट होगा, तो "grayscale" स्टाइल लें
Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

अपने लिए सही स्टाइल चुनने का अभ्यास करें!

Matplotlib के साथ डेटा विज़ुअलाइज़ेशन परिचय

Preparing Video For Download...