Matplotlib基本操作

Posted ayanwan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Matplotlib基本操作相关的知识,希望对你有一定的参考价值。

1、plot线

2、scatter散点图

3、bar状图


# -*- coding: utf-8 -*-
"""
Created on Sun Jul  9 17:20:30 2017

@author: tfygg
"""

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-10,10,20)

y = 2*x+1
z= x**2

plt.figure()
plt.plot(x, y,label = 'y')
plt.plot(x, z, color='red',linestyle='--',label='z')
plt.legend(loc='upper right')
plt.show()

plt.figure()
plt.scatter(x,z)
plt.show()

plt.figure()
plt.bar(x,z)
plt.show()







以上是关于Matplotlib基本操作的主要内容,如果未能解决你的问题,请参考以下文章