3套Matplotlib主题,让图表更好看!
分享3套Matplotlib主题,让图表更好看
seaborn默认主题
import seaborn as sns
import pandas as pd
import matplotlib as mpltips = 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)
-END- 推荐阅读:
10W字《R ggplot2可视化教程1.0》来了! 详解Python列表推导式|迭代器|生成器|匿名函数 Jupyter Notebook的16个超棒插件! 临床WGS/WES/Gene Panel/Single gene异同 一图胜千言,超形象图解NumPy教程! 那些神经网络可视化利器 R Graphics Cookbook中译教程
我的学习小圈子👉 加入 赞、在看就是最大的支持