数组与绘图

面向 MATLAB 用户的 Python

Justin Kiggins

Product Manager

NumPy 数组

  • 数组 = 矩阵
  • 数组可为多维
  • 元素类型相同
面向 MATLAB 用户的 Python

索引 NumPy 数组

print(arr)
[[2, 4, 8, 16, 32]]
  • 从 0 开始索引
print(arr[2])
8
print(arr[0])
2
print(arr[-1])
32
面向 MATLAB 用户的 Python

用 Matplotlib 可视化数据

示例 matplotlib 可视化

面向 MATLAB 用户的 Python

使用 matplotlib

import matplotlib.pyplot as plt
# 创建新图形
plt.figure()

# 绘制 y 关于 x 的曲线 plt.plot(x, y)
# 设置 x/y 轴标签 plt.xlabel('x') plt.ylabel('y')
# 显示图形 plt.show()

面向 MATLAB 用户的 Python

Passons à la pratique !

面向 MATLAB 用户的 Python

Preparing Video For Download...