Como preparar figuras para apresentações

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

Ariel Rokem

Data Scientist

Mudando 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

Escolhendo 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

Voltar ao padrão

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

Os 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

Dicas para escolher o estilo de plotagem

  • Fundos escuros geralmente são menos visíveis.
  • Se a cor for importante, pense em escolher opções que sejam amigá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 “escala de cinza”.
Introdução à Visualização de Dados com a Matplotlib

Pratique escolher o estilo certo para você!

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

Preparing Video For Download...