0

I am making a plot as in:

http://matplotlib.org/examples/mplot3d/polys3d_demo.html

but in the example they declare:

ys[0], ys[-1] = 0, 0

so that the polygons have a point on the x,y plane.

My data does not have zeros at the end points. So, when I plot it, the polygons do not touch the x,y plane as they do nicely in the example. Is there a hack to make the polygons drop to the (x,y) plane even if the f(x,y) datapoint at the end points is not zero?

Here is my code now. The (x,y) plane is determined by the 1D arrays U_array and d_array. The z-variable is called zvar and is a 2D array:

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    xs = U_array
    verts = []
    zs = list(d_array)
    indx = 0
    for z in zs:
      ys = np.copy(zvar[:,indx])
   #  ys[0], ys[-1] = 0, 0
    verts.append(list(zip(xs, ys)))
    indx = indx + 1
    poly = PolyCollection(verts, facecolors = facecolors)
    poly.set_alpha(0.7)
    ax.add_collection3d(poly, zs=zs, zdir='y')
    plt.show()

How can I make my plot without the commented line above where I artificially make my data points zero at the ends?

Thanks. Also, out of curiosity, why is zs in here not really the z-variable? ...

Cokes
  • 3,743
  • 6
  • 30
  • 41
  • I finally figured out a trick. You must concatenate zeros at the end of the z-variable. Then concatenate x[0] and x[-1] on the two ends of the x-variable and y[0] and y[-1] on the two ends of the y variable. This will make the polygon touch the xy plane. – Cokes Jan 10 '14 at 20:12
  • You can answer (and in time accept) your own question. – Schorsch Jan 28 '14 at 17:04

0 Answers0