I practiced drawing a heat map using experimental data.
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns```
Ready with the above code.
## Data reading
#### **`ec_am = pd.read_csv('./ec_am.csv')`**
Data is 6 rows and 10 columns
First, try without specifying any conditions.
heatmap1 = sns.heatmap(ec_am)
plt.savefig("heatmap1.png ")```
![heatmap1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/861630/0777c956-4f60-4010-1554-c4fb1abfce4e.png)
Save the figure in png format named heatmap1 with plt.savefig ("heatmap1.png "). The save destination is the same file as the open jupyter notebook.
Next, try various conditions.
#### **`heatmap2 = sns.heatmap(ec_am, yticklabels=False, cbar=False)`**
```heatmap(ec_am, yticklabels=False, cbar=False)
plt.savefig("heatmap2.png ")```
![heatmap2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/861630/e8b81fe8-7847-04c2-61a8-99a5988eff72.png)
Specify Y-axis labels with yticklabels. Specify the color bar with cbar. If it is False, it disappears.
#### **`heatmap3 = sns.heatmap(ec_am, cmap="Wistia", annot=True, fmt="1.2f")`**
plt.savefig("heatmap3.png ")``` Specify the color with cmap. Display the numerical value of the data with annot. Display up to the xth decimal place with fmt = "1.xf" (x is a positive integer). See beiz notes for color types.
heatmap4 = sns.heatmap(ec_am, cmap="Purples", annot=True, fmt="1.1f", linewidths=.5)
plt.savefig("heatmap4.png ")```
![heatmap4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/861630/c30243fd-cce2-3058-f354-6724e90afffa.png)
Draw lines between cells with linewidths (thickness 0.5 in this case).
Recommended Posts