Colores y estilos
Clase 7 de 18 • Curso de Visualización de Datos con Matplotlib y Seaborn
Resumen
Podemos personalizar mejor nuestros gráficos con diferentes colores y estilos, así, se entenderá mucho mejor nuestras gráficas.
Cómo agregar colores y estilos en Matplotlib
- Estilos de gráficas que hay
print(plt.style.available)
---> Muestra los stilos que tiene matplot
- Usar un estilo de grilla
plt.style.use('seaborn-whitegrid')
Personalizar colores y estilos en Matlab
fig, ax = plt.subplots(figsize = (6,6))
ax.plot(x,x+1, 'r--')
ax.plot(x,x+2, 'bo-')
ax.plot(x,x+3, 'g.:')
ax.plot(x,x+4, 'purple')
Personalizar colores y estilos en Pyplot
Para personalizar con pyplot es un poco más largo cuando programamos, pero se puede personalizar muchísimo más
- Color
fig, ax = plt.subplots(figsize = (6,6))
ax.plot(x,x+1,color = '#D426C8') ---> Color RGB
ax.plot(x,x+2,color = '#66FF89')
ax.plot(x,x+3,color = 'blue') --> Color común
ax.plot(x,x+4, color = 'black')
- Transparencia
(alpha)
y grosor(linewidth)
fig, ax = plt.subplots(figsize = (6,6))
ax.plot(x,x+1,color = '#D426C8', alpha= 0.5, linewidth= 18)
ax.plot(x,x+2,color = '#66FF89', linewidth= 3)
ax.plot(x,x+3,color = 'blue', linewidth= 5)
ax.plot(x,x+4, color = 'black', alpha = 0.3, linewidth= 12)
- Estilo
(linestyle)
y marcadores(marker)
fig, ax = plt.subplots(figsize = (6,6))
ax.plot(x,x+3,color = 'blue', linestyle = 'dashed', marker = 'x')
ax.plot(x,x+4, color = 'black',linestyle = '--', marker = 'P')
- Tamaño de marcadores
(markersize)
y color(markerfacecolor)
fig, ax = plt.subplots(figsize = (6,6))
ax.plot(x,x+3,color = 'blue', linestyle = 'dashed', marker = '8', markersize = 10, markerfacecolor= "#37D842")
ax.plot(x,x+4, color = 'black',linestyle = '--', marker = 'P', markerfacecolor="#FF0000")