python - 我想知道如何使用带有 XYZ 值的 python matplotlib 进行绘制
问题描述
我有一个 XYZ 测量
我尝试了 mplot3d 示例代码,但我不知道。
我想绘制一个图表,显示这些值的高度差异。
我想知道如何将值应用于示例。
有下面的图片
x y z
```
X Y Z
0.0056 -149.00237 0.01375
-11.99014 -148.5314 0.01323
-23.90088 -147.08148 0.01294
-35.67262 -144.68161 0.01386
-47.19637 -141.34179 0.0139
-58.41713 -137.08002 0.01303
-69.24989 -131.93131 0.01319
-79.64266 -125.94063 0.01233
-89.52245 -119.11801 0.0124
-98.81825 -111.51743 0.01235
..........
```
示例代码
```
# This import registers the 3D projection, but is otherwise unused.
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
import matplotlib.pyplot as plt
import numpy as np
n_radii = 8
n_angles = 36
# Make radii and angles spaces (radius r=0 omitted to eliminate duplication).
radii = np.linspace(0.125, 1.0, n_radii)
angles = np.linspace(0, 2*np.pi, n_angles, endpoint=False)[..., np.newaxis]
# Convert polar (radii, angles) coords to cartesian (x, y) coords.
# (0, 0) is manually added at this stage, so there will be no duplicate
# points in the (x, y) plane.
x = np.append(0, (radii*np.cos(angles)).flatten())
y = np.append(0, (radii*np.sin(angles)).flatten())
# Compute z to make the pringle surface.
z = np.sin(-x*y)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_trisurf(x, y, z, linewidth=0.2, antialiased=True)
plt.show()
```
解决方案
推荐阅读
- python - 获取熊猫中第一个带有数字的字符串
- c# - OData 客户端 GetReadStreamAsync 不起作用
- python - Python,一项测试影响另一项
- python-3.x - cluster_centers_ 的排序/索引在 KMeans 聚类 SKlearn 中代表什么
- mysql - Shopware Docker 无法登录 Docker MySQL 数据库
- postgis - 如何使用 AdonisJS 调用数据库函数?
- c - 使用 memcpy 将二维数组复制到新缓冲区
- angular8 - 将数据直接绑定到角度的 mat-checkbox
- botframework - LUIS - 发布到生产和登台
- ruby-on-rails - 如何比较rails中的今天日期和输入日期?