Ammar Ajtar
Quiero agregar un título a un mapa de calor nacido en el mar. Usando Pandas y iPython Notebook
el código está debajo,
a1_p = a1.pivot_table( index='Postcode', columns="Property Type", values="Count", aggfunc=np.mean, fill_value=0)
sns.heatmap(a1_p, cmap="YlGnBu")
los datos son bastante sencillos:
In [179]: a1_p
Out [179]:
Property Type Flat Terraced house Unknown
Postcode
E1 11 0 0
E14 12 0 0
E1W 6 0 0
E2 6 0 0
heatmap
es un axes
función de nivel, por lo que debería poder usar solo plt.title
o ax.set_title
:
%matplotlib inline
import numpy as np
import os
import seaborn as sns
import matplotlib.pyplot as plt
data = np.random.randn(10,12)
ax = plt.axes()
sns.heatmap(data, ax = ax)
ax.set_title('lalala')
plt.show()
Para dar un título para el uso del mapa de calor marino
plt.title("Enter your title", fontsize =20)
o
ax.set(title = "Enter your title")
import seaborn as sns # for data visualization
import matplotlib.pyplot as plt # for data visualization
flight = sns.load_dataset('flights') # load flights datset from GitHub seaborn repository
# reshape flights dataeset in proper format to create seaborn heatmap
flights_df = flight.pivot('month', 'year', 'passengers')
ax = sns.heatmap(flights_df) # create seaborn heatmap
plt.title('Heatmap of Flighr Dataset', fontsize = 20) # title with fontsize 20
plt.xlabel('Years', fontsize = 15) # x-axis label with fontsize 15
plt.ylabel('Monthes', fontsize = 15) # y-axis label with fontsize 15
plt.show()
Salida >>>
Alternativamente sns.plt.suptitle('lalala')
funcionaría si tienes varias subtramas.
-
Seaborn eliminó la exposición a matplotlib.pyplot en su paquete, import
matplotlib.pyplot as plt
y escribeplt.suptitle('lalala')
en cambio– Charlie G.
04/03/2019 a las 22:20
¿Ha sido útil esta solución?
Tu feedback nos ayuda a saber si la solución es correcta y está funcionando. De esta manera podemos revisar y corregir el contenido.
Has probado
plt.title()
?– Fabio Lamanna
22/09/2015 a las 18:12