I am trying to plot a 4D surface plot of netcdf data (attached file). It has 4 dimensions: lat, long, lev, and the value-dust mixing ratio (5 values DU01, DU02...05). As I am very much new to Python, I don't know about it much. I have to plot DU01 (which will be the fill value) vs lat, long, and levels. Sample plot what I need is
.
Any help would be very much helpful and appreciated.
I am getting this error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[59], line 9
7 fig = plt.figure(figsize=(12, 8))
8 ax = fig.add_subplot(111, projection='3d')
----> 9 ax.plot_surface(lon_3d, lat_3d, lev_3d, facecolors=plt.cm.jet(DMR/np.nanmax(DMR)), rstride=1, cstride=1, edgecolor='none', alpha=.8)
10 ax.set_title('DU01 dust mixing ratio')
11 ax.set_xlabel('Longitude')
File C:\ProgramData\anaconda3\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py:1381, in Axes3D.plot_surface(self, X, Y, Z, norm, vmin, vmax, lightsource, **kwargs)
1378 had_data = self.has_data()
1380 if Z.ndim != 2:
-> 1381 raise ValueError("Argument Z must be 2-dimensional.")
1383 Z = cbook._to_unmasked_float_array(Z)
1384 X, Y, Z = np.broadcast_arrays(X, Y, Z)
ValueError: Argument Z must be 2-dimensional.
This code creates 3D surface plot of the data for DU01 mixing ratio value.