Je figuren klaarmaken om te delen

Introductie tot datavisualisatie met Matplotlib

Ariel Rokem

Data Scientist

Plotstijl wijzigen

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()

Introductie tot datavisualisatie met Matplotlib

Een stijl kiezen

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()

Introductie tot datavisualisatie met Matplotlib

Terug naar de standaard

plt.style.use("default")
Introductie tot datavisualisatie met Matplotlib

Beschikbare stijlen

Introductie tot datavisualisatie met Matplotlib

De "bmh"-stijl

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()

Introductie tot datavisualisatie met Matplotlib

Seaborn-stijlen

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()

Introductie tot datavisualisatie met Matplotlib

Richtlijnen voor het kiezen van een stijl

  • Donkere achtergronden zijn vaak minder leesbaar
  • Als kleur telt, kies kleurenblindvriendelijke opties
    • "seaborn-colorblind" of "tableau-colorblind10"
  • Verwacht je dat iemand afdrukt? Gebruik minder inkt
  • Komt het in zwart-wit? Gebruik de "grayscale"-stijl
Introductie tot datavisualisatie met Matplotlib

Oefen met de juiste stijl kiezen!

Introductie tot datavisualisatie met Matplotlib

Preparing Video For Download...