【发布时间】:2022-01-31 18:47:13
【问题描述】:
我已将绘图设置为透明,因此当我在绘图后访问它时,轴和标签看起来很暗 如何将标签和轴设置为“白色”.??
我试过了
import seaborn as sns
DATA=sns.load_dataset("tips")
import matplotlib.pyplot as plt
plt.figure()
sns.set_style(style="white")
ax=sns.clustermap(DATA.corr(),
cmap="viridis")
#ax.xaxis.label.set_color('white')
#ax.yaxis.label.set_color('white')
plt.savefig("clustermap",transparent=True)
请注意,我不想更改“背景”颜色,只更改标签和轴颜色
【问题讨论】:
-
导出的图片格式是什么?并非所有格式都支持透明度。尝试使用 PNG:
plt.savefig("clustermap.png", transparent=True) -
png格式
-
我测试了提供的代码,我得到一个白色背景,也许检查你有最新版本的模块
-
我不想改变背景颜色,只是标签和轴颜色(我是指轴上的所有内容)
-
gist.github.com/mwaskom/7be0963cc57f6c89f7b2,虽然我认为您需要手动更改树状图颜色
标签: python matplotlib seaborn