小编Kal*_*nit的帖子

如何在不添加“刻度”的情况下从下到上移动标签

我如何使用“tick_top”以外的其他东西将 xlabel 定位在图的顶部 - 这会为 x 标签添加一个勾号,而我不想要它。

底部的 xlabel 没有勾号: 在此处输入图片说明

代码:

import numpy as np; np.random.seed(0)
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data, vmin=0, vmax=1)
plt.yticks(rotation=0)
plt.show()
Run Code Online (Sandbox Code Playgroud)

xlabel 在顶部但带有勾号: 在此处输入图片说明

代码:

import numpy as np; np.random.seed(0)
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data, vmin=0, vmax=1)
plt.yticks(rotation=0)
ax.xaxis.tick_top() # x axis on top
ax.xaxis.set_label_position('top')
plt.show()
Run Code Online (Sandbox Code Playgroud)

python plot matplotlib heatmap seaborn

19
推荐指数
2
解决办法
1万
查看次数

标签 统计

heatmap ×1

matplotlib ×1

plot ×1

python ×1

seaborn ×1