In [1]:
# %matplotlib inline
In [2]:
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
In [3]:
list_2d = [[0, 1, 2], [3, 4, 5]]
In [4]:
plt.figure()
sns.heatmap(list_2d)
plt.savefig('data/dst/seaborn_heatmap_list.png')
plt.close('all')
In [5]:
arr_2d = np.arange(-8, 8).reshape((4, 4))
print(arr_2d)
In [6]:
plt.figure()
sns.heatmap(arr_2d)
plt.savefig('data/dst/seaborn_heatmap_ndarray.png')
In [7]:
df = pd.DataFrame(data=arr_2d, index=['a', 'b', 'c', 'd'], columns=['A', 'B', 'C', 'D'])
print(df)
In [8]:
plt.figure()
sns.heatmap(df)
plt.savefig('data/dst/seaborn_heatmap_dataframe.png')
In [9]:
print(type(sns.heatmap(list_2d)))
In [10]:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
sns.heatmap(list_2d, ax=ax)
fig.savefig('data/dst/seaborn_heatmap_list.png')
In [11]:
fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(8, 6))
sns.heatmap(list_2d, ax=axes[0, 0])
sns.heatmap(arr_2d, ax=axes[1, 2])
fig.savefig('data/dst/seaborn_heatmap_list_sub.png')
In [12]:
plt.figure()
sns.heatmap(df, annot=True)
plt.savefig('data/dst/seaborn_heatmap_annot.png')
In [13]:
plt.figure()
sns.heatmap(df, cbar=False)
plt.savefig('data/dst/seaborn_heatmap_no_cbar.png')
In [14]:
plt.figure()
sns.heatmap(df, square=True)
plt.savefig('data/dst/seaborn_heatmap_square.png')
In [15]:
plt.figure()
sns.heatmap(df, vmax=10, vmin=-10, center=0)
plt.savefig('data/dst/seaborn_heatmap_vmax_vmin_center.png')
In [16]:
plt.figure()
sns.heatmap(df, cmap='hot')
plt.savefig('data/dst/seaborn_heatmap_hot.png')
In [17]:
plt.figure()
sns.heatmap(df, cmap='Blues')
plt.savefig('data/dst/seaborn_heatmap_blues.png')
In [18]:
plt.figure()
sns.heatmap(df, cmap='Blues_r')
plt.savefig('data/dst/seaborn_heatmap_blues_r.png')
In [19]:
current_figsize = mpl.rcParams['figure.figsize']
print(current_figsize)
In [20]:
plt.figure(figsize=(9, 6))
sns.heatmap(df, square=True)
plt.savefig('data/dst/seaborn_heatmap_big.png')
In [21]:
current_dpi = mpl.rcParams['figure.dpi']
print(current_dpi)
In [22]:
plt.figure()
sns.heatmap(df, square=True)
plt.savefig('data/dst/seaborn_heatmap_big_2.png', dpi=current_dpi * 1.5)
In [23]:
df_house = pd.read_csv('data/src/house_prices_train.csv', index_col=0)
In [24]:
df_house_corr = df_house.corr()
print(df_house_corr.shape)
In [25]:
print(df_house_corr.head())
In [26]:
plt.figure(figsize=(12, 9))
sns.heatmap(df_house_corr, square=True, vmax=1, vmin=-1, center=0)
plt.savefig('data/dst/seaborn_heatmap_house_price.png')