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绘制三种常见图表的方法:线形图、散点图及柱状图,并通过实例展示了如何设置颜色、线条样式等属性。

119

被折叠的 条评论
为什么被折叠?



