python数据分析基础2_matplotlib
来源:互联网 发布:php base64解码乱码 编辑:程序博客网 时间:2024/06/09 21:30
python科学计算——绘图篇
1.matplotlib库的使用介绍
本课时对matplotlib库的介绍来讲解其安装,并通过实例来讲解其基础使用方法。
in
%matplotlib inline #把图形绘制在页面里import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0,10,1000)y = np.sin(x)z = np.cos(x)plt.figure(figsize=(8,4)) #指定图形的尺寸,和像素点是一一对应的plt.plot(x,y,color='red',label='$sin(x)$') plt.plot(x,z,"b--",label='$cos(x)$') #b blueplt.xlabel(("Time(s)"))plt.ylabel("")plt.title("matplotlib")plt.ylim(-1.2,1.2)plt.legend()fig = plt.gcf()ax = plt.gca()print(fig)print(ax)plt.show()
out
2.mpl_toolkits库使用介绍(一)
通过对mpl_toolkits库的介绍来讲解其安装,并通过结合matplotlib来制作一些简单的3D效果图
3.mpl_toolkits库使用介绍(二)
通过对mpl_toolkits库的介绍来绘制更高级的3D效果图
in
import matplotlib.pyplot as pltfor idx,color in enumerate("rgbyck"): plt.subplot(320+idx+1,axisbg=color) # plt.subplot绘制子图 bg backgroundplt.show()
out
in
#!/usr/bin/env python#-*-coding: utf-8-*-import numpy as npimport matplotlib.pyplot as pltw = np.linspace(0.1,1000,1000) #0.1~1000这样的1000段的数据p = np.abs(1 / (1+0.1j*w))plt.subplot(221)plt.plot(w,p,linewidth=2)plt.ylim(0,1.5)plt.subplot(222)plt.semilogx(w,p,linewidth=2) #对数坐标轴 对x轴取对数坐标plt.ylim(0,1.5)plt.subplot(223)plt.semilogy(w,p,linewidth=2) #对数坐标轴 对y轴取对数坐标plt.ylim(0,1.5)plt.subplot(224)plt.loglog(w,p,linewidth=2) #对数坐标轴 对x轴、y轴都取对数坐标plt.ylim(0,1.5)
out
in
#!/usr/bin/env python#-*-coding: utf-8-*-import numpy as npimport matplotlib.pyplot as pltdata = np.loadtxt("1.txt")width = (data[1,0] - data[0,0])*0.4plt.figure(figsize=(8,5))plt.bar(data[:,0]-width/2, data[:,1],width,label='person') #bar 柱状图plt.xlim(-width, 40+width)plt.xlabel("Age")plt.ylabel("Num")plt.legend()plt.show()
out
in
#!/usr/bin/env python#-*-coding: utf-8-*-import numpy as npimport matplotlib.pyplot as pltplt.figure(figsize=(8,4))x = np.random.random(100) #0~1之间100个随机数y = np.random.random(100)plt.scatter(x,y,s=x*1000,c=y,marker=(5,1),alpha=0.8,lw=2,facecolor="none") #c=y是指colorplt.xlim(0,1) #lim limitplt.ylim(0,1)plt.show()
out
in
plt.scatter?
out
截图
阅读全文
0 0
- python数据分析基础2_matplotlib
- 读书笔记--python数据可视化--001_matplotlib学习
- python画图_matplotlib和pandas
- Python数据分析基础
- Python 数据分析-pandas 基础
- python 数据分析 numpy基础
- 【Python】Python数据分析基础技术03
- 利用python进行数据分析-NumPy基础2
- Python 数据分析包:pandas 基础
- Python 数据分析包:pandas 基础
- Python 数据分析包:pandas 基础
- Python 数据分析包:pandas 基础
- Python 数据分析:pandas 操作基础篇
- Python 数据分析包:pandas 基础
- 利用python进行数据分析-NumPy基础
- Python 数据分析包:pandas 基础
- Python 数据分析包:pandas 基础
- Python数据分析包:pandas 基础
- 【MR】剖析YARN中uber模式
- python数据分析基础1_Pandas
- 随笔
- CGIC库的移植及使用
- 4.运动 transition:时间 属性 运动形式 延迟时间
- python数据分析基础2_matplotlib
- python数据分析基础3_数据整理
- WebSocket原理
- 探究java多线程中正确的单例模式 volatile关键字
- 微信小程序获取当前所在城市
- Windows10上Python3.6通过pip安装包出现UnicodeDecodeError
- SQL语句:Group By总结
- ITEXT5.5.8转html为pdf文档解决linux不显示中文问题
- NOIP2002-----马拦过河卒【经典搜索】