'How to draw a 3D graph like this?

I found a post on LinkedIn as follows: I am wondering if there is any library to draw a 3D plot with its projection like this? This is a general question, but that would be fine to have an example for any dataset. Should we add more details to the graph provided by matplotlib or there is any specific library for this purpose?

enter image description here



Solution 1:[1]

The suggestion of you and S3DEV to use matplotlib points to a nice library that supports 3d drawings:

https://matplotlib.org/stable/api/toolkits/mplot3d.html?highlight=3d#module-mpl_toolkits.mplot3d.axes3d

Note that this particular projection from 3d to 2d is easy to handle yourself. Suppose that we have a 2d-coordinate system with center (0,0). Then you need three 2d-vectors to represent the 3d unit vectors

Set

i = (s*cos(pi/2+1*2pi/3), s*sin(pi/2+1*2pi/3))
j = (s*cos(pi/2+2*2pi/3), s*sin(pi/2+2*2pi/3))
k = (s*cos(pi/2+3*2pi/3), s*sin(pi/2+3*2pi/3))

where s is the size of a unitvector (when drawn in the 2d coordinate system).

To draw the point (x,y,z) you simply compute x*i+y*j+z*k which is a 2d-point.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1