我曾用seaborn来显示热图。但是png并不完整,图片的顶部和底部都有一些矩形,而不是正方形。
import csv
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
weather = pd.read_csv('wetter.csv')
print(weather)
rain = pd.DataFrame(weather,columns=["a","b","c","d","e","f","g"])
print(rain)
sns.heatmap(rain,vmin=0, vmax=7.0, cmap="Blues",center=3.5,square=True,linewidths=1,linecolor='black')
plt.savefig('rain.png',dpi=600)
plt.show()