title: How to use the datasets to fit the 3D-surface?
body: <p>I am trying to fit this X, Y, Z datasets to an unknown surface.  </p>
  
  <p>Unfortunately, linear fitting is not good enough to show the surface data.  I think the polynomial fitting might fit in this case.  In addition, The problem is that I do not know how to build the polynomial fitting function to make the surface fitting done.</p>
  
  <p>Any help would be great.</p>
  
  <p>Thank you</p>
  
  <pre><code>import numpy as np
  from matplotlib import pyplot as plt
  from mpl_toolkits.mplot3d import Axes3D
  
  X = [[2, 2, 2], [1.5, 1.5, 1.5], [0.5, 0.5, 0.5]]
  Y = [[3, 2, 1], [3, 2, 1], [3, 2, 1]]
  Z = [[2.4, 2.5, 2.2], [2.4, 3, 2.5], [4, 3.3, 8]]
  
  # ================= Plot figure =================  ##
  Fontsize_set = {'size': 20}
  fig = plt.figure(figsize=[8, 5], dpi=140, facecolor='w')
  ax = fig.gca(projection='3d')
  ax.grid(color='y', linestyle='--', linewidth=0.5)
  ax.tick_params(labelsize=20)
  ax.set_xlim3d(0, 3)
  ax.set_ylim3d(0, 6)
  ax.set_zlim3d(0, 10)
  ax.view_init(30, 45)
  ax.scatter(X, Y, Z, s=50, color='k', marker='o', linewidth=None, alpha=1)
  # ax.plot_surface(X, Y, Z)
  fig.tight_layout()
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2Z97V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Z97V.png" alt="enter image description here"></a></p>