As you are plotting each vertex individually I think you will need to apply a rotation to each vertex. 3D rotations can be confusing, there are numerous ways to define such a rotation, and depending on how you want to rotate it will depend on which you will choose.
You state you want to rotate it horizontally, in such a 3d picture it is unclear what is meant by this so please forgive me if I'm wrong in assuming you want to rotate it say about the z axis by an angle
To rotate a vector
p which has length 3, we keep the third component constant and apply a rotation to the other two. This is best understood by matrix multiplication but I'll leave the explanation to the Wolfram pages:
p_rotated_x = p_x * sin(theta) - p_y * sin(theta)
p_rotated_y = p_x * sin(theta) + p_y * cos(theta)
p_rotate_z = p_z
This is the rotated components after applying the R_z rotation matrix in the link above.Applying this to your code after importing some trig functions
from numpy import sin, cos
theta = np.radians(30)
for s, e in combinations(np.array(list(product(d,d,d))), 2):
if np.sum(np.abs(s-e)) == d-d:
s_rotated = [s * cos(theta) - s * sin(theta),
s * sin(theta) + s * cos(theta),
e_rotated = [e * cos(theta) - e * sin(theta),
e * sin(theta) + e * cos(theta),
Note the angle is specified in degrees by the trig function need it to be in radians (hence the conversion).
This is quite a simple rotation, and the implementation is somewhat simplistic. This could be improved upon I admit but the basic idea is there. If you want to rotate it a more complex method I recommend reading about Euler angles which is one (for me at least) intuitive way to understand 3d rotations.