python matplotlib 画图

首先,看看都有哪些画图的样式:

import matplotlib.pyplot as plt
print(plt.style.available)

输出所有样式如下:

['seaborn-notebook', 'seaborn-muted', 'seaborn-dark', 'tableau-colorblind10', 'seaborn-colorblind', 'seaborn-deep', 'fast', 'classic', 'bmh', '_classic_test', 'seaborn-bright', 'seaborn-white', 'Solarize_Light2', 'seaborn-paper', 'seaborn-darkgrid', 'grayscale', 'seaborn', 'seaborn-poster', 'seaborn-ticks', 'ggplot', 'fivethirtyeight', 'seaborn-whitegrid', 'seaborn-dark-palette', 'dark_background', 'seaborn-talk', 'seaborn-pastel']
 

使用样式:

plt.style.use('ggplot')

上面所有样式都可以通过调用plt.style.use()函数来使用。

但是经过试验发现,样式要通过组合才能有比较好的效果。

组合一:

plt.style.use('classic')
plt.style.use('seaborn-whitegrid')
plt.style.use('bmh')
plt.style.use('tableau-colorblind10')

效果如下:

组合二、 

plt.style.use('classic')
plt.style.use('seaborn-whitegrid')
plt.style.use('Solarize_Light2')
plt.style.use('ggplot')

效果如下:

 

 

plt画图范式:

# 1. 开figure
fig = plt.figure(figsize=(宽,高)) # 宽高为对应的数字

# 2. 开子图
## 假设子图个数2行1列
ax0 = fig.add_subplot(2,1,1)
ax1 = fig.add_subplot(2,1,2)
 
# 3. 子图绘制 (线图用plot, 图片用imshow)
ax0.plot(x0)
ax0.plot(peaks0, x0[peaks0], "o") #支持多此绘制

ax1.plot(x1, y1)
ax1.plot(peaks1)


# 4. 显示
fig.show()

大家可以尝试不同的组合,找到自己最喜欢的效果。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值