3D 曲面绘图产生不连续的多边形面而不是平滑的曲线

问题描述 投票:0回答:1

我正在尝试在 Python/Matplotlib 中绘制三原子分子 A-B-C 的能量面。我已将键长(B1 和 B2)组合的数据和计算出的分子能量 (MP3) 制成表格,我想将其转换为平滑的 3D 曲面图。类似的 Excel 宏函数输出以下 Excel 表面输出:
Excel surface output 我使用plot_surface在Matplotlib(在Jupyter Notebook中)中实现了类似的图形解决方案:

导入库:

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np

设置数组并从文件中检索数据:

N = [] #Not needed
B1 = [] #Bond 1 Distance
B2 = [] #Bond 2 Distance
SCF = [] #Not needed
MP2 = [] #Not needed
MP3 = [] #Energy
filename = #insert filepath here
f = open(filename, 'r')
for line in f:
    columns = line.split()
    N.append(float(columns[0]))
    B1.append(float(columns[1])) #B1
    B2.append(float(columns[2])) #B2
    SCF.append(float(columns[3]))
    MP2.append(float(columns[4]))
    MP3.append(float(columns[5])) #Energy
f.close()

从键距数组中删除重复值并将键距和能量转换为二维网格:

Xset = set(B1)
Xlist = list(Xset)
Xarray = np.array(Xlist)
Yset = set(B2)
Ylist = list(Yset)
Yarray = np.array(Ylist)
X, Y = np.meshgrid(Xarray, Yarray) #convert X and Y to 2D grids
Zarray = np.array(MP3)
Z = Zarray.reshape(len(Xset), len(Yset)) #convert Z to 2D grid

绘制要输出的数据:

fig = plt.figure(figsize =(10, 10))
ax = fig.add_subplot(111, projection='3d') 
surf = ax.plot_surface(X, Y, Z, cmap="viridis")
fig.colorbar(surf, shrink=0.4)
plt.show()

但是,生成的绘图具有大的多边形分段,并且不是平滑、连续的表面,并且它具有类似于大平面的不准确、平滑的绘图伪影。我对原始版本很好奇,所以我还决定绘制一个线框版本,并得到了类似的令人困惑的结果,看起来像大多边形面。

Plot_surface 和线框版本:
enter image description here

我用散点函数测试了原始文本文件数据,它完美地再现了Excel结果,然后我将结果叠加,发现它们与粗面图匹配得比较好。

散点图和曲面图比较:

enter image description here

我想确保散点数据镜像 Excel,因此我旋转它并找到具有相似最小值的其他匹配几何图形(旋转方向与 Excel 相反)。

散点图正面视图:
enter image description here

因此,我相当确定输入文件包含正确的信息来重新创建准确的曲面图,并且散点图与 Excel 匹配,但为什么曲面图不输出平滑的曲面?与数据分辨率低有关吗?在这些示例中,我仅绘制了 484 个总点。是不是因为数据不是来自自定义方程而是来自外部数据而不起作用?我是否可能需要应用诸如样条拟合之类的东西来平滑表面?

支持信息 这是我用于输入的文本文件的 Pastebin 链接: https://pastebin.com/4fURFjMU 注意:此文件中仅第 2 列(键合距离 1)、第 3 列(键合距离 2)和第 6 列(分子能量)用于任何计算/输入,其他列是所用计算程序的不必要的输出工件。

    1     0.7000     0.7000    -98.37390    -98.57110    -98.58410
    2     0.8000     0.7000    -98.46298    -98.66474    -98.67770
    3     0.9000     0.7000    -98.49247    -98.69853    -98.71140
    4     1.0000     0.7000    -98.49104    -98.70128    -98.71400
    5     1.1000     0.7000    -98.47388    -98.68824    -98.70077
    6     1.2000     0.7000    -98.44935    -98.66785    -98.68011
    7     1.3000     0.7000    -98.42241    -98.64533    -98.65713
    8     1.4000     0.7000    -98.39649    -98.62526    -98.63616
    9     1.5000     0.7000    -98.37423    -98.61235    -98.62225
   10     1.6000     0.7000    -98.35668    -98.60720    -98.61857
   11     1.7000     0.7000    -98.34331    -98.60679    -98.62365
   12     1.8000     0.7000    -98.33310    -98.60857    -98.63398
   13     1.9000     0.7000    -98.32513    -98.61123    -98.64673
   14     2.0000     0.7000    -98.31873    -98.61426    -98.66026
   15     2.1000     0.7000    -98.31342    -98.61750    -98.67377
   16     2.2000     0.7000    -98.30890    -98.62091    -98.68698
   17     2.3000     0.7000    -98.30495    -98.62448    -98.69982
   18     2.4000     0.7000    -98.30144    -98.62823    -98.71235
   19     2.5000     0.7000    -98.29826    -98.63216    -98.72463
   20     2.6000     0.7000    -98.29535    -98.63628    -98.73676
   21     2.7000     0.7000    -98.29267    -98.64059    -98.74882
   22     2.8000     0.7000    -98.29017    -98.64508    -98.76086
   23     0.7000     0.8000    -99.16190    -99.36656    -99.37968
   24     0.8000     0.8000    -99.25060    -99.45989    -99.47287
   25     0.9000     0.8000    -99.27908    -99.49270    -99.50547
   26     1.0000     0.8000    -99.27631    -99.49407    -99.50656
   27     1.1000     0.8000    -99.25767    -99.47943    -99.49155
   28     1.2000     0.8000    -99.23153    -99.45716    -99.46884
   29     1.3000     0.8000    -99.20265    -99.43195    -99.44309
   30     1.4000     0.8000    -99.17395    -99.40705    -99.41745
   31     1.5000     0.8000    -99.14855    -99.38995    -99.39814
   32     1.6000     0.8000    -99.12939    -99.38736    -99.39451
   33     1.7000     0.8000    -99.11589    -99.39252    -99.40563
   34     1.8000     0.8000    -99.10640    -99.40007    -99.42466
   35     1.9000     0.8000    -99.09959    -99.40781    -99.44615
   36     2.0000     0.8000    -99.09451    -99.41507    -99.46723
   37     2.1000     0.8000    -99.09058    -99.42173    -99.48680
   38     2.2000     0.8000    -99.08738    -99.42785    -99.50465
   39     2.3000     0.8000    -99.08468    -99.43356    -99.52093
   40     2.4000     0.8000    -99.08232    -99.43898    -99.53594
   41     2.5000     0.8000    -99.08019    -99.44420    -99.54995
   42     2.6000     0.8000    -99.07823    -99.44929    -99.56324
   43     2.7000     0.8000    -99.07640    -99.45434    -99.57601
   44     2.8000     0.8000    -99.07467    -99.45937    -99.58843
   45     0.7000     0.9000    -99.58864    -99.80002    -99.81317
   46     0.8000     0.9000    -99.67767    -99.89382    -99.90673
   47     0.9000     0.9000    -99.70605    -99.92665    -99.93924
   48     1.0000     0.9000    -99.70298    -99.92786    -99.94003
   49     1.1000     0.9000    -99.68402    -99.91305    -99.92471
   50     1.2000     0.9000    -99.65762    -99.89070    -99.90176
   51     1.3000     0.9000    -99.62853    -99.86562    -99.87598
   52     1.4000     0.9000    -99.59946    -99.84093    -99.85046
   53     1.5000     0.9000    -99.57256    -99.82211    -99.83006
   54     1.6000     0.9000    -99.55109    -99.81828    -99.82283
   55     1.7000     0.9000    -99.53576    -99.82431    -99.83076
   56     1.8000     0.9000    -99.52503    -99.83345    -99.84900
   57     1.9000     0.9000    -99.51739    -99.84272    -99.87136
   58     2.0000     0.9000    -99.51180    -99.85116    -99.89396
   59     2.1000     0.9000    -99.50752    -99.85866    -99.91512
   60     2.2000     0.9000    -99.50411    -99.86533    -99.93437
   61     2.3000     0.9000    -99.50128    -99.87138    -99.95181
   62     2.4000     0.9000    -99.49882    -99.87697    -99.96775
   63     2.5000     0.9000    -99.49663    -99.88227    -99.98253
   64     2.6000     0.9000    -99.49463    -99.88739    -99.99645
   65     2.7000     0.9000    -99.49278    -99.89242   -100.00975
   66     2.8000     0.9000    -99.49103    -99.89742   -100.02263
   67     0.7000     1.0000    -99.80989   -100.02698   -100.03998
   68     0.8000     1.0000    -99.89942   -100.12138   -100.13404
   69     0.9000     1.0000    -99.92799   -100.15456   -100.16677
   70     1.0000     1.0000    -99.92504   -100.15607   -100.16773
   71     1.1000     1.0000    -99.90625   -100.14167   -100.15268
   72     1.2000     1.0000    -99.88019   -100.12002   -100.13027
   73     1.3000     1.0000    -99.85169   -100.09617   -100.10552
   74     1.4000     1.0000    -99.82366   -100.07370   -100.08189
   75     1.5000     1.0000    -99.79815   -100.05657   -100.06278
   76     1.6000     1.0000    -99.77677   -100.04861   -100.05181
   77     1.7000     1.0000    -99.75999   -100.04909   -100.05118
   78     1.8000     1.0000    -99.74713   -100.05428   -100.05986
   79     1.9000     1.0000    -99.73726   -100.06130   -100.07460
   80     2.0000     1.0000    -99.72953   -100.06863   -100.09226
   81     2.1000     1.0000    -99.72334   -100.07570   -100.11074
   82     2.2000     1.0000    -99.71826   -100.08232   -100.12894
   83     2.3000     1.0000    -99.71397   -100.08852   -100.14640
   84     2.4000     1.0000    -99.71027   -100.09439   -100.16299
   85     2.5000     1.0000    -99.70702   -100.10001   -100.17879
   86     2.6000     1.0000    -99.70412   -100.10547   -100.19390
   87     2.7000     1.0000    -99.70150   -100.11085   -100.20847
   88     2.8000     1.0000    -99.69911   -100.11620   -100.22262
   89     0.7000     1.1000    -99.91553   -100.13738   -100.15002
   90     0.8000     1.1000   -100.00550   -100.23231   -100.24451
   91     0.9000     1.1000   -100.03434   -100.26589   -100.27752
   92     1.0000     1.1000   -100.03165   -100.26783   -100.27878
   93     1.1000     1.1000   -100.01319   -100.25398   -100.26414
   94     1.2000     1.1000    -99.98755   -100.23305   -100.24230
   95     1.3000     1.1000    -99.95960   -100.21012   -100.21831
   96     1.4000     1.1000    -99.93214   -100.18851   -100.19538
   97     1.5000     1.1000    -99.90689   -100.17090   -100.17590
   98     1.6000     1.1000    -99.88487   -100.15941   -100.16188
   99     1.7000     1.1000    -99.86645   -100.15450   -100.15474
  100     1.8000     1.1000    -99.85139   -100.15474   -100.15479
  101     1.9000     1.1000    -99.83915   -100.15815   -100.16104
  102     2.0000     1.1000    -99.82916   -100.16323   -100.17176
  103     2.1000     1.1000    -99.82090   -100.16902   -100.18526
  104     2.2000     1.1000    -99.81399   -100.17505   -100.20023
  105     2.3000     1.1000    -99.80812   -100.18108   -100.21584
  106     2.4000     1.1000    -99.80306   -100.18703   -100.23157
  107     2.5000     1.1000    -99.79866   -100.19289   -100.24718
  108     2.6000     1.1000    -99.79477   -100.19868   -100.26254
  109     2.7000     1.1000    -99.79130   -100.20443   -100.27762
  110     2.8000     1.1000    -99.78819   -100.21016   -100.29244
  111     0.7000     1.2000    -99.95657   -100.18246   -100.19456
  112     0.8000     1.2000   -100.04688   -100.27779   -100.28932
  113     0.9000     1.2000   -100.07598   -100.31172   -100.32258
  114     1.0000     1.2000   -100.07358   -100.31407   -100.32414
  115     1.1000     1.2000   -100.05546   -100.30071   -100.30987
  116     1.2000     1.2000   -100.03022   -100.28034   -100.28848
  117     1.3000     1.2000   -100.00264   -100.25794   -100.26491
  118     1.4000     1.2000    -99.97543   -100.23652   -100.24214
  119     1.5000     1.2000    -99.95006   -100.21808   -100.22203
  120     1.6000     1.2000    -99.92732   -100.20394   -100.20586
  121     1.7000     1.2000    -99.90750   -100.19468   -100.19444
  122     1.8000     1.2000    -99.89053   -100.18996   -100.18819
  123     1.9000     1.2000    -99.87614   -100.18889   -100.18701
  124     2.0000     1.2000    -99.86397   -100.19043   -100.19033
  125     2.1000     1.2000    -99.85365   -100.19370   -100.19729
  126     2.2000     1.2000    -99.84486   -100.19807   -100.20697
  127     2.3000     1.2000    -99.83732   -100.20311   -100.21857
  128     2.4000     1.2000    -99.83081   -100.20854   -100.23142
  129     2.5000     1.2000    -99.82513   -100.21422   -100.24506
  130     2.6000     1.2000    -99.82016   -100.22005   -100.25916
  131     2.7000     1.2000    -99.81575   -100.22597   -100.27350
  132     2.8000     1.2000    -99.81184   -100.23197   -100.28794
  133     0.7000     1.3000    -99.96204   -100.19141   -100.20281
  134     0.8000     1.3000   -100.05258   -100.28701   -100.29775
  135     0.9000     1.3000   -100.08192   -100.32123   -100.33118
  136     1.0000     1.3000   -100.07982   -100.32393   -100.33299
  137     1.1000     1.3000   -100.06204   -100.31098   -100.31905
  138     1.2000     1.3000   -100.03715   -100.29101   -100.29799
  139     1.3000     1.3000   -100.00985   -100.26890   -100.27467
  140     1.4000     1.3000    -99.98275   -100.24743   -100.25187
  141     1.5000     1.3000    -99.95720   -100.22824   -100.23121
  142     1.6000     1.3000    -99.93387   -100.21227   -100.21360
  143     1.7000     1.3000    -99.91299   -100.19994   -100.19955
  144     1.8000     1.3000    -99.89456   -100.19127   -100.18932
  145     1.9000     1.3000    -99.87844   -100.18593   -100.18296
  146     2.0000     1.3000    -99.86442   -100.18343   -100.18034
  147     2.1000     1.3000    -99.85225   -100.18322   -100.18113
  148     2.2000     1.3000    -99.84169   -100.18477   -100.18493
  149     2.3000     1.3000    -99.83252   -100.18766   -100.19124
  150     2.4000     1.3000    -99.82452   -100.19154   -100.19958
  151     2.5000     1.3000    -99.81752   -100.19615   -100.20952
  152     2.6000     1.3000    -99.81137   -100.20130   -100.22065
  153     2.7000     1.3000    -99.80594   -100.20683   -100.23268
  154     2.8000     1.3000    -99.80113   -100.21266   -100.24534
  155     0.7000     1.4000    -99.94865   -100.18100   -100.19161
  156     0.8000     1.4000   -100.03937   -100.27679   -100.28663
  157     0.9000     1.4000   -100.06893   -100.31124   -100.32021
  158     1.0000     1.4000   -100.06712   -100.31424   -100.32224
  159     1.1000     1.4000   -100.04968   -100.30160   -100.30856
  160     1.2000     1.4000   -100.02510   -100.28192   -100.28775
  161     1.3000     1.4000    -99.99804   -100.25996   -100.26459
  162     1.4000     1.4000    -99.97103   -100.23837   -100.24175
  163     1.5000     1.4000    -99.94534   -100.21860   -100.22069
  164     1.6000     1.4000    -99.92159   -100.20139   -100.20216
  165     1.7000     1.4000    -99.89998   -100.18706   -100.18653
  166     1.8000     1.4000    -99.88054   -100.17567   -100.17397
  167     1.9000     1.4000    -99.86319   -100.16711   -100.16449
  168     2.0000     1.4000    -99.84778   -100.16114   -100.15804
  169     2.1000     1.4000    -99.83415   -100.15747   -100.15446
  170     2.2000     1.4000    -99.82212   -100.15579   -100.15356
  171     2.3000     1.4000    -99.81152   -100.15579   -100.15511
  172     2.4000     1.4000    -99.80216   -100.15719   -100.15884
  173     2.5000     1.4000    -99.79390   -100.15973   -100.16446
  174     2.6000     1.4000    -99.78659   -100.16321   -100.17171
  175     2.7000     1.4000    -99.78012   -100.16745   -100.18031
  176     2.8000     1.4000    -99.77436   -100.17227   -100.19002
  177     0.7000     1.5000    -99.92602   -100.16084   -100.17061
  178     0.8000     1.5000   -100.01689   -100.25677   -100.26568
  179     0.9000     1.5000   -100.04668   -100.29142   -100.29939
  180     1.0000     1.5000   -100.04516   -100.29466   -100.30161
  181     1.1000     1.5000   -100.02802   -100.28228   -100.28815
  182     1.2000     1.5000   -100.00374   -100.26279   -100.26755
  183     1.3000     1.5000    -99.97691   -100.24090   -100.24452
  184     1.4000     1.5000    -99.94999   -100.21918   -100.22166
  185     1.5000     1.5000    -99.92425   -100.19896   -100.20034
  186     1.6000     1.5000    -99.90025   -100.18092   -100.18126
  187     1.7000     1.5000    -99.87819   -100.16530   -100.16473
  188     1.8000     1.5000    -99.85812   -100.15217   -100.15085
  189     1.9000     1.5000    -99.83997   -100.14147   -100.13964
  190     2.0000     1.5000    -99.82365   -100.13307   -100.13103
  191     2.1000     1.5000    -99.80902   -100.12678   -100.12491
  192     2.2000     1.5000    -99.79594   -100.12241   -100.12115
  193     2.3000     1.5000    -99.78426   -100.11975   -100.11959
  194     2.4000     1.5000    -99.77385   -100.11860   -100.12005
  195     2.5000     1.5000    -99.76456   -100.11878   -100.12236
  196     2.6000     1.5000    -99.75628   -100.12010   -100.12633
  197     2.7000     1.5000    -99.74888   -100.12240   -100.13178
  198     2.8000     1.5000    -99.74227   -100.12554   -100.13853
  199     0.7000     1.6000    -99.89961   -100.13637   -100.14528
  200     0.8000     1.6000    -99.99065   -100.23241   -100.24041
  201     0.9000     1.6000   -100.02066   -100.26724   -100.27424
  202     1.0000     1.6000   -100.01939   -100.27068   -100.27662
  203     1.1000     1.6000   -100.00254   -100.25848   -100.26334
  204     1.2000     1.6000    -99.97853   -100.23913   -100.24291
  205     1.3000     1.6000    -99.95192   -100.21726   -100.22000
  206     1.4000     1.6000    -99.92515   -100.19540   -100.19716
  207     1.5000     1.6000    -99.89944   -100.17485   -100.17573
  208     1.6000     1.6000    -99.87534   -100.15621   -100.15637
  209     1.7000     1.6000    -99.85307   -100.13974   -100.13936
  210     1.8000     1.6000    -99.83266   -100.12550   -100.12480
  211     1.9000     1.6000    -99.81407   -100.11344   -100.11270
  212     2.0000     1.6000    -99.79722   -100.10347   -100.10300
  213     2.1000     1.6000    -99.78199   -100.09546   -100.09560
  214     2.2000     1.6000    -99.76827   -100.08926   -100.09039
  215     2.3000     1.6000    -99.75592   -100.08472   -100.08723
  216     2.4000     1.6000    -99.74482   -100.08167   -100.08599
  217     2.5000     1.6000    -99.73485   -100.07997   -100.08650
  218     2.6000     1.6000    -99.72589   -100.07948   -100.08864
  219     2.7000     1.6000    -99.71783   -100.08005   -100.09226
  220     2.8000     1.6000    -99.71059   -100.08157   -100.09720
  221     0.7000     1.7000    -99.87244   -100.11054   -100.11865
  222     0.8000     1.7000    -99.96364   -100.20672   -100.21385
  223     0.9000     1.7000    -99.99385   -100.24170   -100.24778
  224     1.0000     1.7000    -99.99282   -100.24530   -100.25031
  225     1.1000     1.7000    -99.97622   -100.23323   -100.23719
  226     1.2000     1.7000    -99.95247   -100.21396   -100.21691
  227     1.3000     1.7000    -99.92609   -100.19209   -100.19413
  228     1.4000     1.7000    -99.89950   -100.17010   -100.17136
  229     1.5000     1.7000    -99.87390   -100.14927   -100.14992
  230     1.6000     1.7000    -99.84985   -100.13020   -100.13046
  231     1.7000     1.7000    -99.82754   -100.11313   -100.11325
  232     1.8000     1.7000    -99.80702   -100.09813   -100.09839
  233     1.9000     1.7000    -99.78826   -100.08517   -100.08590
  234     2.0000     1.7000    -99.77118   -100.07419   -100.07573
  235     2.1000     1.7000    -99.75569   -100.06507   -100.06778
  236     2.2000     1.7000    -99.74166   -100.05769   -100.06196
  237     2.3000     1.7000    -99.72897   -100.05192   -100.05815
  238     2.4000     1.7000    -99.71752   -100.04763   -100.05621
  239     2.5000     1.7000    -99.70718   -100.04469   -100.05601
  240     2.6000     1.7000    -99.69785   -100.04298   -100.05744
  241     2.7000     1.7000    -99.68942   -100.04238   -100.06036
  242     2.8000     1.7000    -99.68181   -100.04278   -100.06463
  243     0.7000     1.8000    -99.84606   -100.08495   -100.09231
  244     0.8000     1.8000    -99.93742   -100.18127   -100.18760
  245     0.9000     1.8000    -99.96781   -100.21639   -100.22164
  246     1.0000     1.8000    -99.96698   -100.22011   -100.22428
  247     1.1000     1.8000    -99.95062   -100.20815   -100.21130
  248     1.2000     1.8000    -99.92711   -100.18892   -100.19118
  249     1.3000     1.8000    -99.90097   -100.16702   -100.16853
  250     1.4000     1.8000    -99.87461   -100.14491   -100.14588
  251     1.5000     1.8000    -99.84921   -100.12384   -100.12452
  252     1.6000     1.8000    -99.82531   -100.10442   -100.10508
  253     1.7000     1.8000    -99.80311   -100.08689   -100.08785
  254     1.8000     1.8000    -99.78266   -100.07133   -100.07292
  255     1.9000     1.8000    -99.76393   -100.05773   -100.06032
  256     2.0000     1.8000    -99.74684   -100.04603   -100.05001
  257     2.1000     1.8000    -99.73131   -100.03614   -100.04189
  258     2.2000     1.8000    -99.71722   -100.02795   -100.03588
  259     2.3000     1.8000    -99.70446   -100.02136   -100.03186
  260     2.4000     1.8000    -99.69290   -100.01623   -100.02972
  261     2.5000     1.8000    -99.68244   -100.01247   -100.02932
  262     2.6000     1.8000    -99.67298   -100.00994   -100.03057
  263     2.7000     1.8000    -99.66441   -100.00856   -100.03333
  264     2.8000     1.8000    -99.65665   -100.00821   -100.03749
  265     0.7000     1.9000    -99.82122   -100.06039   -100.06708
  266     0.8000     1.9000    -99.91273   -100.15686   -100.16247
  267     0.9000     1.9000    -99.94326   -100.19210   -100.19659
  268     1.0000     1.9000    -99.94261   -100.19592   -100.19935
  269     1.1000     1.9000    -99.92645   -100.18403   -100.18650
  270     1.2000     1.9000    -99.90318   -100.16483   -100.16652
  271     1.3000     1.9000    -99.87731   -100.14289   -100.14404
  272     1.4000     1.9000    -99.85121   -100.12066   -100.12154
  273     1.5000     1.9000    -99.82607   -100.09938   -100.10032
  274     1.6000     1.9000    -99.80241   -100.07966   -100.08099
  275     1.7000     1.9000    -99.78043   -100.06175   -100.06384
  276     1.8000     1.9000    -99.76018   -100.04574   -100.04898
  277     1.9000     1.9000    -99.74163   -100.03163   -100.03642
  278     2.0000     1.9000    -99.72470   -100.01938   -100.02611
  279     2.1000     1.9000    -99.70930   -100.00890   -100.01799
  280     2.2000     1.9000    -99.69533   -100.00012   -100.01196
  281     2.3000     1.9000    -99.68266    -99.99291   -100.00791
  282     2.4000     1.9000    -99.67118    -99.98717   -100.00573
  283     2.5000     1.9000    -99.66078    -99.98280   -100.00530
  284     2.6000     1.9000    -99.65135    -99.97970   -100.00650
  285     2.7000     1.9000    -99.64281    -99.97775   -100.00924
  286     2.8000     1.9000    -99.63506    -99.97686   -100.01339
  287     0.7000     2.0000    -99.79818   -100.03723   -100.04333
  288     0.8000     2.0000    -99.88982   -100.13384   -100.13881
  289     0.9000     2.0000    -99.92047   -100.16919   -100.17301
  290     1.0000     2.0000    -99.91995   -100.17309   -100.17585
  291     1.1000     2.0000    -99.90398   -100.16125   -100.16313
  292     1.2000     2.0000    -99.88095   -100.14206   -100.14331
  293     1.3000     2.0000    -99.85536   -100.12008   -100.12101
  294     1.4000     2.0000    -99.82956   -100.09772   -100.09870
  295     1.5000     2.0000    -99.80473   -100.07625   -100.07766
  296     1.6000     2.0000    -99.78139   -100.05627   -100.05850
  297     1.7000     2.0000    -99.75972   -100.03803   -100.04150
  298     1.8000     2.0000    -99.73976   -100.02164   -100.02676
  299     1.9000     2.0000    -99.72149   -100.00711   -100.01430
  300     2.0000     2.0000    -99.70484    -99.99441   -100.00408
  301     2.1000     2.0000    -99.68969    -99.98348    -99.99601
  302     2.2000     2.0000    -99.67595    -99.97423    -99.99001
  303     2.3000     2.0000    -99.66350    -99.96656    -99.98597
  304     2.4000     2.0000    -99.65221    -99.96038    -99.98377
  305     2.5000     2.0000    -99.64199    -99.95556    -99.98331
  306     2.6000     2.0000    -99.63272    -99.95203    -99.98447
  307     2.7000     2.0000    -99.62431    -99.94967    -99.98715
  308     2.8000     2.0000    -99.61668    -99.94839    -99.99124
  309     0.7000     2.1000    -99.77698   -100.01560   -100.02118
  310     0.8000     2.1000    -99.86870   -100.11234   -100.11672
  311     0.9000     2.1000    -99.89943   -100.14777   -100.15097
  312     1.0000     2.1000    -99.89903   -100.15174   -100.15390
  313     1.1000     2.1000    -99.88325   -100.13995   -100.14130
  314     1.2000     2.1000    -99.86046   -100.12076   -100.12166
  315     1.3000     2.1000    -99.83516   -100.09872   -100.09955
  316     1.4000     2.1000    -99.80969   -100.07624   -100.07746
  317     1.5000     2.1000    -99.78521   -100.05459   -100.05663
  318     1.6000     2.1000    -99.76223   -100.03437   -100.03768
  319     1.7000     2.1000    -99.74092   -100.01584   -100.02086
  320     1.8000     2.1000    -99.72133    -99.99913   -100.00628
  321     1.9000     2.1000    -99.70342    -99.98427    -99.99395
  322     2.0000     2.1000    -99.68711    -99.97123    -99.98383
  323     2.1000     2.1000    -99.67230    -99.95996    -99.97584
  324     2.2000     2.1000    -99.65888    -99.95038    -99.96988
  325     2.3000     2.1000    -99.64672    -99.94241    -99.96585
  326     2.4000     2.1000    -99.63572    -99.93592    -99.96364
  327     2.5000     2.1000    -99.62575    -99.93083    -99.96313
  328     2.6000     2.1000    -99.61671    -99.92704    -99.96422
  329     2.7000     2.1000    -99.60851    -99.92443    -99.96681
  330     2.8000     2.1000    -99.60107    -99.92291    -99.97079
  331     0.7000     2.2000    -99.75750    -99.99553   -100.00061
  332     0.8000     2.2000    -99.84927   -100.09238   -100.09618
  333     0.9000     2.2000    -99.88005   -100.12788   -100.13047
  334     1.0000     2.2000    -99.87977   -100.13191   -100.13348
  335     1.1000     2.2000    -99.86416   -100.12014   -100.12102
  336     1.2000     2.2000    -99.84162   -100.10095   -100.10155
  337     1.3000     2.2000    -99.81662   -100.07884   -100.07967
  338     1.4000     2.2000    -99.79149   -100.05624   -100.05781
  339     1.5000     2.2000    -99.76739   -100.03441   -100.03722
  340     1.6000     2.2000    -99.74480   -100.01397   -100.01849
  341     1.7000     2.2000    -99.72391    -99.99520   -100.00187
  342     1.8000     2.2000    -99.70473    -99.97824    -99.98747
  343     1.9000     2.2000    -99.68722    -99.96313    -99.97529
  344     2.0000     2.2000    -99.67131    -99.94987    -99.96529
  345     2.1000     2.2000    -99.65689    -99.93841    -99.95739
  346     2.2000     2.2000    -99.64384    -99.92867    -99.95149
  347     2.3000     2.2000    -99.63204    -99.92055    -99.94749
  348     2.4000     2.2000    -99.62136    -99.91395    -99.94528
  349     2.5000     2.2000    -99.61169    -99.90876    -99.94475
  350     2.6000     2.2000    -99.60293    -99.90487    -99.94579
  351     2.7000     2.2000    -99.59498    -99.90218    -99.94831
  352     2.8000     2.2000    -99.58777    -99.90059    -99.95219
  353     0.7000     2.3000    -99.73961    -99.97697    -99.98154
  354     0.8000     2.3000    -99.83140   -100.07392   -100.07713
  355     0.9000     2.3000    -99.86223   -100.10949   -100.11145
  356     1.0000     2.3000    -99.86204   -100.11357   -100.11453
  357     1.1000     2.3000    -99.84661   -100.10183   -100.10221
  358     1.2000     2.3000    -99.82431   -100.08261   -100.08294
  359     1.3000     2.3000    -99.79962   -100.06041   -100.06129
  360     1.4000     2.3000    -99.77485   -100.03768   -100.03968
  361     1.5000     2.3000    -99.75114   -100.01568   -100.01934
  362     1.6000     2.3000    -99.72897    -99.99504   -100.00084
  363     1.7000     2.3000    -99.70850    -99.97608    -99.98444
  364     1.8000     2.3000    -99.68977    -99.95895    -99.97023
  365     1.9000     2.3000    -99.67270    -99.94372    -99.95821
  366     2.0000     2.3000    -99.65722    -99.93038    -99.94835
  367     2.1000     2.3000    -99.64322    -99.91889    -99.94058
  368     2.2000     2.3000    -99.63057    -99.90916    -99.93478
  369     2.3000     2.3000    -99.61915    -99.90108    -99.93087
  370     2.4000     2.3000    -99.60882    -99.89455    -99.92872
  371     2.5000     2.3000    -99.59948    -99.88943    -99.92823
  372     2.6000     2.3000    -99.59102    -99.88562    -99.92929
  373     2.7000     2.3000    -99.58335    -99.88301    -99.93179
  374     2.8000     2.3000    -99.57639    -99.88148    -99.93564
  375     0.7000     2.4000    -99.72316    -99.95991    -99.96389
python matplotlib 3d surface
1个回答
0
投票

enter image description here

我想你不应该

meshgrid
你的数组,而只是重塑它们

import matplotlib.pyplot as plt
from numpy import array

data_by_rows = array([[float(v)for v in line.split()]for line in open('data')]).T
x, y, z = data_by_rows[1], data_by_rows[2], data_by_rows[5]
x, y, z = [arr.reshape(22, 22) for arr in (x, y, z)]

fig, ax = plt.subplots(subplot_kw={'projection':'3d'})
ax.plot_surface(x, y, z)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.view_init(azim=120)
plt.show()
© www.soinside.com 2019 - 2024. All rights reserved.