Adding the line: from mpl_toolkits.mplot3d import Axes3D
solved but I had to remove ax.set_box_aspect([1,1,1]) as it raised an error. The figure I get is:

Now I am just wandering why it just plots directions for 2 different b values and not for all three I have in my dw_scheme,
Thanks ,
Rosella
ps. please find attached also the dw_scheme:

The version of Python isn’t the problem here, it’s the version of the matplotlib Python package that needs to be at least 3.3, as @maxpietsch pointed out. Updating it will depend on your system, but can typically be done using pip.

That’s simply because the colourmap used to pick colours for the different shells (hsv) is cyclic: it’s the same colour for b=0 and b=b_{max}. So that red dot in the middle is actually at b=0, as you should be able to verify by rotating the display. You can pick a different, non-cyclic colourmap if you want, just change line 4 to list one of the available choices.

Hi
I just have an ultimate question about this 3d spherical representation of acquisition scheme. What does opacity specifically represent?
thank you
rosella

The points shown as transparent correspond to the opposite direction of one of the opaque dots. Only the opaque directions are actually listed in the encoding scheme, and are in fact acquired. But since diffusion is symmetric, there should be no difference in terms of diffusion signal between images with diffusion weighting along some direction g or its opposite -g. But it does impact on other things like eddy-current induced distortions. So this allows you to see how well the shell is sampled in terms of the diffusion signal (all dots) or in terms of its resilience to eddy-currents (opaque dots only).

Just one more question, if I had to insert axes in this figure, which ones should I use (labels)?
Would they be x, y and z directions in q-space? Which units of measure, though?

Yes, the axes would effectively be in 3D q-space, though more precisely in the b-space. And as coded, the units of measure are in b – same as the values provided in the DW encoding table.