A Perspective of The Vast Distance In Our Universe (Orion Constellation Project)

Hey all, this is my Orion Constellation project. To spice it up a little, I also added a different star that was considered relatively close to it in order to put into perspective how vast and unknown our universe really is. I think that it mostly went very well, but I’d like to know if there are any ways I can improve my code or make my graphs look better.

1: Here I’m just importing some assets

%matplotlib notebook
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

2: Now I’m adding the data for the stars that I’ll graph

# Orion
x = [-0.41, 0.57, 0.07, 0.00, -0.29, -0.32,-0.50,-0.23, -0.23]
y = [4.12, 7.71, 2.36, 9.10, 13.35, 8.13, 7.19, 13.25,13.43]
z = [2.06, 0.84, 1.56, 2.07, 2.36, 1.72, 0.66, 1.25,1.38]

#other stars

#McCook & Sion White Dwarf
x2 = -4.3
y2 = -4.8
z2 = 3.7

3: Now I’m making the 2D graph

fig = plt.figure()
fig.add_subplot(1, 1, 1)
plt.scatter(x, y, color='red')
plt.scatter(x2, y2, color='blue')
plt.legend(['Orion Constellation', 'McCook & Sion White Dwarf'])
plt.title('Orion Constellation & McCook & Sion White Dwarf Star')

(I’d add the photo but I’m a new user so I can only add one)

4: Finally, I’m going to create the 3D graph

fig_3d = plt.figure()
fig_3d.add_subplot(1, 1, 1, projection="3d")
constellation3d = plt.scatter(x,y,z, c='red')
constellation3d2 = plt.scatter([x2], [y2], [z2], color='blue')
plt.legend(['Orion C.', 'M&S White Dwarf'], loc='lower center')
plt.title('3d Rotational Graph of Orion Constellation & McCook & Sion Dwarf Star')

Any recommendations to make my code or graph better? Thanks for reading, cheers :slight_smile:

1 Like

I like it. It kind of matches the point of the original paper from which the data was obtained. For a mild critique I’d suggest adding some labels to those axes. Without them I’m not sure what the scale even is unless I start digging through text to find it. That sort of information should always always be included. Might be worth shifting the label away from the ticks too since it obscures that information but I appreciate the colour and a handy key to denote the two different datasets.

Please also have a close look at the z-axis of your points. I believe they all sit at z=0.0. Using the standard matplotlib.pyplot.sctatter() function only allows for 2D plotting.

You need to be using the .scatter() method of your 3D axis object which supports z data…

ax3dobj = fig.add_subplot(1,1,1,projection="3d")
1 Like