1

我有 3 个包含 X、Y 和 Z 值的列表,完整列表如下:

X = [132.54, 132.54, 132.54, 132.54, 132.54, 132.54, 132.54, 132.54, 132.54, 132.54, 132.54, 134.546, 134.546, 134.546, 134.546, 134.546, 134.546, 134.546, 134.546, 134.546, 134.546, 134.546, 136.551, 136.551, 136.551, 136.551, 136.551, 136.551, 136.551, 136.551, 136.551, 136.551, 136.551, 138.557, 138.557, 138.557, 138.557, 138.557, 138.557, 138.557, 138.557, 138.557, 138.557, 138.557, 140.562, 140.562, 140.562, 140.562, 140.562, 140.562, 140.562, 140.562, 140.562, 140.562, 140.562, 142.568, 142.568, 142.568, 142.568, 142.568, 142.568, 142.568, 142.568, 142.568, 142.568, 142.568, 144.573, 144.573, 144.573, 144.573, 144.573, 144.573, 144.573, 144.573, 144.573, 144.573, 144.573, 146.579, 146.579, 146.579, 146.579, 146.579, 146.579, 146.579, 146.579, 146.579, 146.579, 146.579, 148.584, 148.584, 148.584, 148.584, 148.584, 148.584, 148.584, 148.584, 148.584, 148.584, 148.584, 150.59, 150.59, 150.59, 150.59, 150.59, 150.59, 150.59, 150.59, 150.59, 150.59, 150.59, 152.595, 152.595, 152.595, 152.595, 152.595, 152.595, 152.595, 152.595, 152.595, 152.595, 152.595, 154.601, 154.601, 154.601, 154.601, 154.601, 154.601, 154.601, 154.601, 154.601, 154.601, 154.601, 156.606, 156.606, 156.606, 156.606, 156.606, 156.606, 156.606, 156.606, 156.606, 156.606, 156.606, 158.612, 158.612, 158.612, 158.612, 158.612, 158.612, 158.612, 158.612, 158.612, 158.612, 158.612, 160.617, 160.617, 160.617, 160.617, 160.617, 160.617, 160.617, 160.617, 160.617, 160.617, 160.617]
Y = [1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375, 1317.489501953125, 1317.4967041015625, 1317.50390625, 1317.5111083984375, 1317.518310546875, 1317.5255126953125, 1317.53271484375, 1317.5399169921875, 1317.547119140625, 1317.5543212890625, 1317.5615234375]
Z = [4251.0, 4709.0, 4964.0, 4841.0, 5150.0, 5566.0, 5849.0, 5126.0, 4776.0, 4159.0, 4587.0, 15026.0, 16042.0, 17385.0, 18204.0, 18756.0, 18429.0, 20108.0, 18208.0, 18137.0, 15512.0, 14252.0, 38640.0, 40912.0, 44742.0, 48256.0, 51276.0, 48700.0, 48630.0, 47534.0, 47528.0, 37621.0, 36378.0, 63476.0, 68681.0, 72606.0, 77005.0, 83461.0, 84781.0, 80830.0, 78657.0, 74265.0, 64688.0, 58954.0, 72568.0, 76691.0, 85765.0, 88176.0, 95847.0, 94039.0, 92193.0, 90114.0, 86131.0, 73637.0, 69138.0, 65324.0, 69272.0, 77007.0, 80101.0, 87474.0, 83800.0, 81599.0, 80097.0, 76092.0, 67502.0, 61812.0, 51300.0, 55933.0, 61503.0, 63763.0, 69422.0, 67678.0, 64683.0, 63100.0, 59392.0, 53528.0, 48526.0, 39004.0, 42287.0, 46422.0, 48064.0, 53608.0, 51926.0, 49335.0, 47674.0, 45192.0, 40570.0, 36978.0, 29110.0, 31968.0, 35257.0, 36317.0, 40040.0, 39242.0, 37815.0, 36077.0, 34165.0, 30798.0, 28342.0, 22130.0, 24130.0, 27180.0, 27668.0, 30156.0, 29506.0, 29791.0, 27266.0, 26196.0, 24205.0, 21713.0, 16681.0, 18604.0, 20717.0, 21186.0, 23593.0, 22869.0, 23007.0, 21917.0, 20445.0, 18478.0, 16866.0, 13039.0, 14626.0, 16060.0, 16290.0, 18006.0, 17579.0, 17736.0, 17396.0, 15980.0, 14696.0, 12509.0, 10144.0, 11442.0, 12436.0, 12937.0, 14124.0, 13466.0, 14254.0, 13358.0, 12897.0, 11405.0, 9914.0, 8173.0, 9561.0, 10162.0, 11155.0, 11221.0, 11320.0, 11545.0, 10513.0, 10939.0, 9546.0, 8476.0, 6618.0, 8130.0, 8309.0, 9303.0, 9082.0, 9210.0, 9172.0, 8472.0, 8792.0, 7922.0, 6550.0]

我使用 matplotlib 创建一个线框,如下所示:

X=sorted(set(X))
Y=sorted(set(Y))
X,Y=np.meshgrid(X,Y)
fig=plt.figure()
ax=fig.add_subplot(111,projection='3d')
ax.plot_wireframe(X,Y,Z)
plt.show()

代码运行,没有抱怨,但我得到的图片真的很奇怪(对我来说),所以我的问题是:

  1. 谁能向我解释为什么接线(可以这么说)是这样安排的?
  2. 我如何决定“如何”连接我的数据(我为什么需要?我期待这个函数将连接每个网格坐标的 Z 值)。
  3. 原来的 X、Y 和 Z 的长度怎么可能是 165,但在执行我的网格网格 X 和 Y 之后的长度是 11(11*11 = 121,缺少 44 个值?)

在此处输入图像描述

4

1 回答 1

1

您需要重塑Z数组:

XX, YY = meshgrid(X, Y)
ZZ = reshape(Z, XX.shape)
ax.plot_wireframe(XX, YY, ZZ)
于 2013-04-03T14:29:25.183 回答