10-matplotlib-子图

#!/usr/bin/python
# -*- coding:utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

'''
    - matplotlib 对象简介
        FigureCanvas
        Figure
        Axes
    - figure = plt.figure()
        Figure 实例
        可以添加axes实例
    
    - ax =fig.add_subplot(111)
        返回Axes实例;
        参数一: 子图总行数
        参数二: 子图总列数
        参数三: 子图位置
        在Figure上添加Axes的常用方法
        
'''

# 生成一个序列
x = np.arange(1,100)

# 生成一个对象
fig = plt.figure()

# 生成一个 2*2 的子图结构
ax1 = fig.add_subplot(221)
ax1.plot(x,-x)

ax2 = fig.add_subplot(222)
ax2.plot(x,x)

ax3 = fig.add_subplot(223)
ax3.plot(x,x*x)

ax4 = fig.add_subplot(224)
ax4.plot(x,np.log(x))

plt.show()

在未来面前,我们永远都是孩子。不断思考,不断学习,才能让我们走的更远。

个人主页:https://www.oceaneyes.cn/

个人学习博客:http://oceaneyes.top/

CSDN:https://blog.csdn.net/qq_16123129 

 长按二维码关注,一起交流学习~~~

发布了41 篇原创文章 · 获赞 33 · 访问量 5471

猜你喜欢

转载自blog.csdn.net/qq_16123129/article/details/88674158