Home > database >  How to plot a 3D grid with a list of xmin, xmax, ymin, ymax, and z values in Python?
How to plot a 3D grid with a list of xmin, xmax, ymin, ymax, and z values in Python?

Time:11-13

I am just getting into Python and have run into a small problem that I am having trouble solving. I have five lists, each list contains a list of minimum x values, minimum y values, maximum x values, maximum y values and a list of z values.

I am not sure how to turn these lists into a 3D surface plot and would welcome any advice that anyone could give me. I believe that I can use matplotlib for this work, but I am not sure how to implement this. When this is plotted I am expecting it to look something like a Qbert plot with squares at varying height.

The code I have so far is shown below

x_min = [0, 5, 10, 15]
x_max = [5, 10, 15, 20]
y_min = [0, 5, 10, 15] 
y_max = [5, 10, 15, 20]
z = [0, 0, 3, 0, 2]

# Make a 3D Surface Plot

CodePudding user response:

you should probably familiarize yourself with enter image description here

a more optimized approach is to bundle your drawings into 1 ax.voxels call with a very big filtered input array, but you have to have to have the same block size for all your blocks or it may become more complicated, you have to divide the space into blocks and figure out which blocks should be drawn using logical operation, so you will have to give your space some thought ... and it may not be faster than the above code.

  • Related