Como preparar figuras para compartilhamento

Introdução à Visualização de Dados com a Matplotlib

Ariel Rokem

Data Scientist

Como alterar o estilo do gráfico

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

Introdução à Visualização de Dados com a Matplotlib

Como escolher um estilo

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

Introdução à Visualização de Dados com a Matplotlib

Como voltar ao padrão

plt.style.use("default")
Introdução à Visualização de Dados com a Matplotlib

Estilos disponíveis

Introdução à Visualização de Dados com a Matplotlib

O estilo "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()

Introdução à Visualização de Dados com a Matplotlib

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

Introdução à Visualização de Dados com a Matplotlib

Orientações para escolher o estilo do gráfico

  • Fundos escuros geralmente são menos visíveis
  • Se a cor for importante, pense em escolher opções favoráveis para quem tem daltonismo
    • “seaborn-colorblind” ou “tableau-colorblind10”
  • Se você acha que alguém vai querer imprimir sua figura, use menos tinta
  • Se for imprimir em preto e branco, use o estilo “grayscale”
Introdução à Visualização de Dados com a Matplotlib

Treine para escolher o estilo certo!

Introdução à Visualização de Dados com a Matplotlib

Preparing Video For Download...