要創(chuàng)建帶有顏色條的熱圖,可以使用Seaborn庫的heatmap()函數(shù),并設(shè)置參數(shù)cbar=True。
下面是一個示例代碼:
import seaborn as sns
import matplotlib.pyplot as plt
# 創(chuàng)建數(shù)據(jù)
data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# 創(chuàng)建熱圖
sns.heatmap(data, cbar=True)
plt.show()
運行這段代碼將創(chuàng)建一個帶有顏色條的熱圖,其中顏色條顯示了數(shù)據(jù)值與顏色之間的對應(yīng)關(guān)系。您可以根據(jù)需要調(diào)整數(shù)據(jù)和其他參數(shù)來自定義熱圖的樣式。