#!/usr/bin/python
# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
import numpy as np

#绘制散点图
def drawScatter(heights,weights):
    #创建散点图
    #第一个参数为点的横坐标
    #第二个参数为点的纵坐标
    plt.scatter(heights,weights)
    plt.xlabel('Heights')
    plt.ylabel('Weight')
    plt.title('Heights & Weight of Students')
    plt.show()


def drawLine(w, b):
    plt.xlabel("x")
    plt.ylabel("y")
    x = np.arange(0, 10)
    y = w*x + b

    plt.plot(x, y)
    plt.show()


def drawScatterAndLine(p, q, w, b):
    plt.scatter(p, q)
    plt.xlabel('p')
    plt.ylabel('q')
    plt.title('line regesion')

    x = np.arange(0, 11)
    y = w * x + b

    plt.plot(x, y, color='red')
    plt.show()


def mul_image():
    plt.figure(1)  # 创建图表1
    plt.figure(2)  # 创建图表2
    ax1 = plt.subplot(211)  # 在图表2中创建子图1
    ax2 = plt.subplot(212)  # 在图表2中创建子图2
    x = np.linspace(0, 3, 100)
    for i in range(5):
        plt.figure(1)
        plt.plot(x, np.exp(i * x / 3))
        plt.sca(ax1)
        plt.plot(x, np.sin(i * x))
        plt.sca(ax2)
        plt.plot(x, np.cos(i * x))
    plt.show()


if __name__ == '__main__':
    # heights = [1.5, 1.7]
    # weights = [43, 61]
    # drawScatter(heights,weights)
    # drawLine(1,2)
    mul_image()