pythonic生物人

3套Matplotlib主题,让图表更好看!

分享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)

Image

下面分享三套主题:下载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)
Image

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)
Image

rose-pine.mplstyle

plt.style.use('你电脑路径/themes/rose-pine.mplstyle')
sns.relplot(
    data=tips,
    x="消费金额 ($)",
    y="小费金额 ($)",
    hue="客人性别",
    col="是否吸烟", 
    palette=["#006a8e", "#b1283a"],
    s=200)
Image

-END-

推荐阅读:

Image

我的学习小圈子👉
加入

赞、在看就是最大的支持Image