分享3套Matplotlib主题,让图表更好看
seaborn默认主题
import seaborn as sns
import pandas as pd
import matplotlib as mpl
tips = pd.read_csv('./sns_data/tips.csv')
sns.relplot(
data=tips,
x="消费金额 ($)",
y="小费金额 ($)",
hue="客人性别",
col="是否吸烟",
palette=["#006a8e", "#b1283a"],
s=200)
下面分享三套主题:
下载https://github.com/h4pZ/rose-pine-matplotlib/archive/refs/heads/main.zip本地路径例如为:你电脑路径/themes
使用时,指定即可,例如plt.style.use('你电脑路径/themes/rose-pine-dawn.mplstyle')
举个例子,
rose-pine-dawn.mplstyle
plt.style.use('你电脑路径/themes/rose-pine-dawn.mplstyle')
sns.relplot(
data=tips,
x="消费金额 ($)",
y="小费金额 ($)",
hue="客人性别",
col="是否吸烟",
palette=["#006a8e", "#b1283a"],
s=200)
rose-pine-moon.mplstyle
plt.style.use('你电脑路径/themes/rose-pine-moon.mplstyle')
sns.relplot(
data=tips,
x="消费金额 ($)",
y="小费金额 ($)",
hue="客人性别",
col="是否吸烟",
palette=["#006a8e", "#b1283a"],
s=200)
rose-pine.mplstyle
plt.style.use('你电脑路径/themes/rose-pine.mplstyle')
sns.relplot(
data=tips,
x="消费金额 ($)",
y="小费金额 ($)",
hue="客人性别",
col="是否吸烟", #行方向按照"是否吸烟"绘制子图
palette=["#006a8e", "#b1283a"],
s=200)