目录

前言

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

(一)不同风格

1.说明:

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

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

2.使用:

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

3.代码使用:

以“dark_background”风格为例。

# 导入模块
import matplotlib.pyplot as plt
import 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系列(十二)---绘图风格的介绍

2.bmh

4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍

3.fivethirtyeight

4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍

4.ggplot

4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍

5.grayscale

4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍

6.Solarize_Light2

4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍

作者:Mark

日期:2019/03/12 周二

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案