gpt4 book ai didi

python - Seaborn设置样式删除了despine配置的边框

转载 作者:行者123 更新时间:2023-12-03 16:13:51 24 4
gpt4 key购买 nike

考虑以下情节:

import matplotlib.pyplot as plt
import seaborn as sns

Data = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", hue="smoker", data = Data, legend_out = False, aspect = 2)
g.set(xlabel = "independent", ylabel = "dependent")
sns.despine(fig=None, ax=None, top=False, right=False, left=False, bottom=False, offset=None, trim=False)
plt.show()

enter image description here



现在,如果我添加设置:
sns.set(rc={'figure.figsize':(10,5)}, font_scale=1.5)
sns.set_style({'axes.facecolor':'white', 'grid.color': '.8', 'font.family':'Times New Roman'})

它删除了我要保留的边框:

enter image description here



如果您能帮助我知道什么是问题以及如何解决它,我将不胜感激。

最佳答案

也许您想忽略seaborn的样式,而只是直接设置所需的参数?

import matplotlib.pyplot as plt
import seaborn as sns

rc = {'figure.figsize':(10,5),
'axes.facecolor':'white',
'axes.grid' : True,
'grid.color': '.8',
'font.family':'Times New Roman',
'font.size' : 15}
plt.rcParams.update(rc)

Data = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", hue="smoker", data = Data, legend_out = False, aspect = 2)
g.set(xlabel = "independent", ylabel = "dependent")
sns.despine(fig=None, ax=None, top=False, right=False, left=False, bottom=False, offset=None, trim=False)
plt.show()

enter image description here

关于python - Seaborn设置样式删除了despine配置的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55026154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com