1 year ago

#388176

test-img

burakdur

3D structured array plotting having different sizes

I am basically trying to create a 3-D plot. I have a 3D array and it has different sizes. Let's exemplify it.

I import my data however the issue is that I need to implement a code giving me 3D plot of this data. I tried the following but that's saying **shape mismatch: objects cannot be broadcast to a single shape** It's kind of structured data. Then, this is how the data looks like in MATLAB

WHOLE DATA SELECT UN_DTE PYTHON UNT_DTE First column

col = ['UN_DTE','UN_DTF','UN_SM05','UN_SM10','UN_SM15','D1_DTE', 'D1_DTF', 'D1_SM05', 'D1_SM10', 'D1_SM15', 'D2_DTE','D2_DTF','D2_SM05','D2_SM10','D2_SM15','D3_DTE','D3_DTF','D3_SM05','D3_SM10','D3_SM15']
df = []
for i in range(len(col)):
    df.append(pd.DataFrame(mat[col[i]]))

fig = plt.figure()
ax = plt.axes(projection='3d')
xup = pd.DataFrame(df[0][0][0]).shape[0]
yup = pd.DataFrame(df[0][0][0]).shape[1]
xline = np.arange(0,xup,1)
yline = np.arange(0,yup,1)
X_line, Y_line = np.meshgrid(xline, yline)
ax.plot_surface(X_line, Y_line, df[0][0][0])
plt.show()

If I modify the last row as ax.plot_surface(X_line, Y_line, df[0][0][0][0]) it says: ValueError: Argument Z must be 2-dimensional.

I'd appreciate if any of you give me some tips about how to plot them exactly. In addition to this, I was also wondering if I am able plot whole data of that input in one figure, let's say UN_DTE.

python

numpy

plot

3d

surface

0 Answers

Your Answer

Accepted video resources