目录
在matplotlib里默认有好几种绘图的风格,今天来作一下简单介绍。
当不设置风格时,便是默认的风格。
风格 | 说明 |
---|---|
dark_background | 黑背景 |
bmh | 贝叶斯风格 |
fivethirtyeight | 无边框风格 |
ggplot | ggplot也是一个绘图的模块,就是套用的这种风格 |
grayscale | 灰度风格 |
Solarize_Light2 | 淡黄背景 |
设置风格的语句:
plt.style.use(‘Solarize_Light2‘)
以“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()
4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍
原文:https://www.cnblogs.com/zyg123/p/10519983.html