Python, matplotlib, heatmap

matplotlib で heatmap

In [1]: import pandas as pd

In [3]: import matplotlib.pyplot as plt

In [4]: import numpy as np

In [5]: df = pd.DataFrame(data=np.random.randn(10,10))

In [6]: df.head()
Out[6]: 
          0         1         2         3         4         5         6  \
0 -1.402152  1.153875  0.283203 -1.856490 -1.243209 -1.438785 -0.171101   
1 -0.817763 -0.714656  1.550122  1.513990 -0.887257  0.917620 -1.543439   
2  1.610987 -0.233679  1.418550  0.350056  0.383738 -0.500331 -0.792056   
3  1.635342 -0.800014 -0.685777  1.424357 -0.572256 -0.222426  0.899391   
4  1.331677 -0.469561 -0.236700  0.407837  1.903806 -1.540179 -0.502556   

          7         8         9  
0 -0.729585  0.326825 -0.567811  
1  0.130574  0.289366  0.690935  
2 -0.388085 -0.820987 -0.128087  
3 -0.901560 -0.717865  1.606376  
4 -0.649525 -0.535125 -1.038398  

In [7]: plt.imshow(df, interpolation='None', cmap='YlOrRd')
Out[7]: <matplotlib.image.AxesImage at 0x82f0b38>

f:id:nekoyukimmm:20150325180003p:plain

あと、お楽しみは、、、

plt.xkcd()
Out[8]: <matplotlib.rc_context at 0x7be4a20>

plt.imshow(df, interpolation='None', cmap='YlOrRd')
Out[9]: <matplotlib.image.AxesImage at 0x8587160>

f:id:nekoyukimmm:20150325180005p:plain

うにゃ~っとなる。