9种方法,一键美化Python图表

Matplotlib、Seaborn默认参数不好看,美化需要大量代码。

本次分享9种方法,一键美化图表,看看那个是你的菜。


1 Matplotlib style sheets

Matplotlib内置多类style sheets,

一行代码使用,

plt.style.use('Solarize_Light2')

详细介绍👉: 详解Python matplotlib深度美化(第二期)


2 seaborn style sheets

 seanborn内置了五套style设置,分别为darkgrid, whitegrid, dark, white, ticks,

 一行代码使用,

import seaborn as sns
sns.set_style('darkgrid')  #设置style'darkgrid'

详细介绍👉: Python seaborn美化篇-风格style


3 qbstyles

qbstyles提供两种Matplotlib style:dark和light:

matplotlib代码中添加两行代码即可:

from qbstyles import mpl_style
mpl_style(dark=False) #开启light主题

详细介绍👉:当Matplotlib遇见qbstyles! 


4 matplotx

matplotx整合了多种可视化主题,比Matplotlib内置主题优美,例如,

 matplotlib代码中添加两行代码即可使用matplotx:

import matplotx

#仅需以上一行代码调用solarized的'dark'主题
plt.style.use(matplotx.styles.solarized['dark'])

详细介绍👉:当Matplotlib遇上matplotx


5 aquarel

aquarel可轻松拯救matplotlib丑陋的默认出图,提供多种绘图浅色light和深色weight绘图主题,极大丰富matplotlib的plt.style库。

 matplotlib代码中使用aquarel:

from aquarel import load_theme

theme = load_theme("arctic_light")
theme.apply()
# 在这里添加绘图代码
theme.apply_transforms()

详细介绍👉:当Matplotlib遇见漂亮的aquarel~


6 SciencePlots 

Matplotlib扩展工具SciencePlots,一行代码绘制science、nature、ieee等要求的图形

 使用SciencePlots,

import scienceplots #导入scienceplots

plt.style.use('science') #使用scienceplots中的science主题

详细介绍👉:一行代码science、nature图表!


7 cyberpunk 

cyberpunk让图表变得“赛博朋克”。

 使用,

import mplcyberpunk

plt.style.use("cyberpunk")  #调用cyberpunk style

详细介绍👉:当matplotlib遇见“赛博朋克”


8 matplotlib.pyplot.xkcd

一行代码可将所有Matplotlib和Seaborn绘制的图形变为手绘风格。

 使用,

import matplotlib.pyplot as plt
with plt.xkcd():
    绘图代码

详细介绍👉:一行Python代码让图形秒变「手绘风」


9  cutecharts

cutecharts可以将Python的强表现能力和Javascript的交互性完美结合,实现萌萌的图表。

使用,

def pie_radius():
    chart = Pie("Pie")
    chart.set_options(
        labels=['我是卢本伟2号', 'Faker', 'Easyhoon', 'Pawn', 'Dopa'],
        inner_radius=0,
    )
    chart.add_series([6, 5, 1, 2, 4])
    return chart


pie_radius().render_notebook()

详细介绍👉:python可视化60|一款蠢萌蠢萌的可视化工具 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_21478261

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值