目录

[TOC]

前言

在matplotlib里默认有好几种绘图的风格,今天来作一下简单介绍。

(一)不同风格

1.说明:

当不设置风格时,便是默认的风格。

风格 说明
dark_background 黑背景
bmh 贝叶斯风格
fivethirtyeight 无边框风格
ggplot ggplot也是一个绘图的模块,就是套用的这种风格
grayscale 灰度风格
Solarize_Light2 淡黄背景

2.使用:

设置风格的语句:
plt.style.use('Solarize_Light2')

3.代码使用:

以“dark_background”风格为例。

# 导入模块import matplotlib.pyplot as pltimport numpy as np# 数据x = np.linspace(-5, 5, 50)y = x**2# 设置风格plt.style.use('dark_background')# 绘图plt.plot(x, y)# 展示plt.show()

(二)例子演示

1.dark_background

4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍插图
01.png

2.bmh

4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍插图1
02.png

3.fivethirtyeight

4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍插图2
03.png

4.ggplot

4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍插图3
04.png

5.grayscale

4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍插图4
05.png

6.Solarize_Light2

4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍插图5
06.png

作者:Mark

日期:2019/03/12 周二

文章转载于:https://www.jianshu.com/p/2a412b648038

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《4.12Python数据处理篇之Matplotlib系列(十二)—绘图风格的介绍
   

还没有人抢沙发呢~