# 用python画动态三维轨迹_Python学习（一） —— matplotlib绘制三维轨迹图

python file_name.py

Matplotlib是Python的一个绘图库，想面将讲解如何使用这个库来绘制三维线段，以此检测SLAM算法的输出结果（电脑配置Python 2.7）。

2.1. 绘制基本三维曲线

# import necessary module

from mpl_toolkits.mplot3d import axes3d

import matplotlib.pyplot as plt

import numpy as np

# you can replace this using with open

first_2000 = data1[:, 3]

second_2000 = data1[:, 7]

third_2000 = data1[:, 11]

# print to check data

print first_2000

print second_2000

print third_2000

# new a figure and set it into 3d

fig = plt.figure()

ax = fig.gca(projection='3d')

# set figure information

ax.set_title("3D_Curve")

ax.set_xlabel("x")

ax.set_ylabel("y")

ax.set_zlabel("z")

# draw the figure, the color is r = read

figure = ax.plot(first_2000, second_2000, third_2000, c='r')

plt.show()

ax = fig.gca(projection='3d')

2.2. 同一张图中绘制多个三维曲线

# import necessary module

from mpl_toolkits.mplot3d import axes3d

import matplotlib.pyplot as plt

import numpy as np

# you replace this using with open

first_2000 = data1[:, 3]

second_2000 = data1[:, 7]

third_2000 = data1[:, 11]

first_1000 = data2[:, 3]

second_1000 = data2[:, 7]

third_1000 = data2[:, 11]

# new a figure and set it into 3d

fig = plt.figure()

ax = fig.gca(projection='3d')

# set figure information

ax.set_title("3D_Curve")

ax.set_xlabel("x")

ax.set_ylabel("y")

ax.set_zlabel("z")

# draw the figure, the color is r = read

figure1 = ax.plot(first_2000, second_2000, third_2000, c='r')

figure2 = ax.plot(first_1000, second_1000, third_1000, c='b')

plt.show()

2.3. 将区域划分后绘制三维图像

# import necessary module

from mpl_toolkits.mplot3d import axes3d

import matplotlib.pyplot as plt

import numpy as np

# you replace this using with open

first_2000 = data1[:, 3]

second_2000 = data1[:, 7]

third_2000 = data1[:, 11]

first_1500 = data2[:, 3]

second_1500 = data2[:, 7]

third_1500 = data2[:, 11]

# new a figure and set it into 3d

fig = plt.figure()

# ############ first subplot ############

ax = fig.add_subplot(2, 2, 1, projection='3d')

ax.set_title("3D_Curve1")

ax.set_xlabel("x")

ax.set_ylabel("y")

ax.set_zlabel("z")

# draw the figure, the color is r = read

figure1 = ax.plot(first_2000, second_2000, third_2000, c='r')

figure2 = ax.plot(first_1500, second_1500, third_1500, c='b')

# ############ second subplot ############

ax = fig.add_subplot(2, 2, 2, projection='3d')

# set figure information

ax.set_title("3D_Curve2")

ax.set_xlabel("x")

ax.set_ylabel("y")

ax.set_zlabel("z")

# draw the figure, the color is r = read

figure1 = ax.plot(first_2000, second_2000, third_2000, c='r')

figure2 = ax.plot(first_1500, second_1500, third_1500, c='b')

# ############ third subplot ############

ax = fig.add_subplot(2, 2, 3, projection='3d')

# set figure information

ax.set_title("3D_Curve3")

ax.set_xlabel("x")

ax.set_ylabel("y")

ax.set_zlabel("z")

# draw the figure, the color is r = read

figure1 = ax.plot(first_2000, second_2000, third_2000, c='r')

figure2 = ax.plot(first_1500, second_1500, third_1500, c='b')

# ############ fourth subplot ############

ax = fig.add_subplot(2, 2, 4, projection='3d')

# set figure information

ax.set_title("3D_Curve4")

ax.set_xlabel("x")

ax.set_ylabel("y")

ax.set_zlabel("z")

# draw the figure, the color is r = read

figure1 = ax.plot(first_2000, second_2000, third_2000, c='r')

figure2 = ax.plot(first_1500, second_1500, third_1500, c='b')

plt.show()

ax = fig.add_subplot(2, 2, 1, projection='3d')

Python学习-使用matplotlib画动态多图

python学习之matplotlib绘制动图（FuncAnimation()参数）

1.函数FuncAnimation(fig,func,frames,init_func,interval,blit)是绘制动图的主要函数,其参数如下: a.fig 绘制动图的画布名称 b.func自定 ...

Python使用matplotlib绘制三维曲线

【转】使用Python matplotlib绘制股票走势图

Matplotlib学习---用matplotlib画箱线图（boxplot）

【Python环境】matplotlib - 2D 与 3D 图的绘制

2015-10-30数据科学自媒体 类MATLAB API 最简单的入门是从类 MATLAB API 开始,它被设计成兼容 MATLAB 绘图函数. 让我们加载它: from pylab import ...

matplotlib绘制三维图

Python教程：matplotlib 绘制双Y轴曲线图

Email系列（QQ邮箱 + 含附件的邮箱案例 + 项目实战）

infopath发布的提示“无法解析SOAP消息”(The SOAP message cannot be parsed)问题解决方案

Groovy 模版引擎

1. Introduction Groovy supports multiple ways to generate text dynamically including GStrings, print ...

Scanner sc=new Scanner(System.in); System.out.println("请输入一个正整数:"); int ss=sc.nextInt(); i ...

USE “schema_name” in PostgreSQL

http://timmurphy.org/tag/mysql/ http://timmurphy.org/2009/11/17/use-schema_name-in-postgresql/ ===== ...

table边框美化