Dan*_*ty2 18 python-3.x seaborn
鉴于以下热图,我将如何删除轴标题('月'和'年')?
import seaborn as sns
# Load the example flights dataset and conver to long-form
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# Draw a heatmap with the numeric values in each cell
sns.heatmap(flights, annot=True, fmt="d", linewidths=.5)
Run Code Online (Sandbox Code Playgroud)
Dan*_*ty2 24
在调用之前,先使用sns.heatmap
轴plt.subplots
,然后使用set_xlabel
和set_ylabel
.例如:
import seaborn as sns
import matplotlib.pyplot as plt
# Load the example flights dataset and conver to long-form
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# ADDED: Extract axes.
fig, ax = plt.subplots(1, 1, figsize = (15, 15), dpi=300)
# Draw a heatmap with the numeric values in each cell
sns.heatmap(flights, annot=True, fmt="d", linewidths=.5)
# ADDED: Remove labels.
ax.set_ylabel('')
ax.set_xlabel('')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19103 次 |
最近记录: |