visualization - Plot transparent 3D boxes using gnuplot -


i have data file "data.txt" contains coordinates of borders of several boxes in 3 dimensions. each line represents single box. file contains on 100 boxes.

        x_min x_max y_min y_max z_min z_max         -0.2 0.2 -0.2 0.2 -0.2 0.2         0.2 0.4 -0.2 0.2 -0.2 0.2         ....         ...         .. 

now want plot that. in 2 dimensions easy using

plot "boxes.txt" u 1:2:3:4 w boxxyerrorbars  

with (x-value):(y-value):(half width):(half height).

than this: enter image description here

but how can achieve in 3 dimensions? didn't find solution problem.

i found solution using python , matplotlib.

import numpy np import matplotlib.pyplot plt import random mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot plt  fig = plt.figure() ax = fig.gca(projection='3d')   dim = 3;  # unit cube cube = [[[0.0,1.0],[0.0,0.0],[0.0,0.0]],\         [[0.0,0.0],[0.0,1.0],[0.0,0.0]],\         [[0.0,0.0],[0.0,0.0],[0.0,1.0]],\         [[1.0,1.0],[0.0,1.0],[0.0,0.0]],\         [[1.0,0.0],[1.0,1.0],[0.0,0.0]],\         [[1.0,1.0],[0.0,0.0],[0.0,1.0]],\         [[1.0,1.0],[1.0,1.0],[0.0,1.0]],\         [[0.0,0.0],[1.0,1.0],[0.0,1.0]],\         [[0.0,0.0],[0.0,1.0],[1.0,1.0]],\         [[0.0,1.0],[0.0,0.0],[1.0,1.0]],\         [[1.0,1.0],[0.0,1.0],[1.0,1.0]],\         [[0.0,1.0],[1.0,1.0],[1.0,1.0]]]  # number of cubes numb_cubes = 5  # array positions [x, y, z] pos = [[0 x in range(dim)] y in range(numb_cubes)]    k  in range(numb_cubes):     d in range(dim):         pos[k][d] = random.uniform(-1,1)  # size of cubes size_of_cubes = [0 y in range(numb_cubes)]   k in range(numb_cubes):     size_of_cubes[k] = random.random()  # limits xmin, xmax = -1, 1 ymin, ymax = -1, 1 zmin, zmax = -1, 1  n in range(numb_cubes):     k in range(len(cube)):             x = np.linspace(cube[k][0][0]*size_of_cubes[n]+pos[n][0], cube[k][0][1]*size_of_cubes[n]+pos[n][0], 2)             y = np.linspace(cube[k][1][0]*size_of_cubes[n]+pos[n][1], cube[k][1][1]*size_of_cubes[n]+pos[n][1], 2)             z = np.linspace(cube[k][2][0]*size_of_cubes[n]+pos[n][2], cube[k][2][1]*size_of_cubes[n]+pos[n][2], 2)              ax.plot(x, y, z, 'black', lw=1)             ax.set_xlim([xmin,xmax])             ax.set_ylim([ymin,ymax])             ax.set_zlim([zmin,ymax]) 

the result get:

enter image description here

i still interested in solution gnuplot or faster solution python.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -