Orion Constellation Project

Hi everyone,
Here is my first project submitted to Codecademy.
Please let me know if there is any issue to fix. :smiley:

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

# 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]

#2d figure
fig = plt.figure()
fig.add_subplot(1, 1, 1)
plt.title('Orion constellation 2D graphic')
plt.scatter(x, y, color='red')
plt.show()

#3d figure
fig_3d = plt.figure()
constellation3d = fig_3d.add_subplot(1, 1, 1, projection='3d')
plt.title('Orion constellation 3D graphic')
constellation3d.scatter(x, y, z, color='green')
plt.show()

It all looks sensible to me but consider adding some labels to your axes. Without them what you’re actually plotting isn’t as clear. Ideally someone else could view the figure and be able to understand it without having to read masses of accompanying text. It’s not always possible but you should be aiming towards that whenever possible.

Thanks for reply,
It is interesting that Z axes can’t be labelled by using plt.zlabel() :thinking:
I have to label them in this way:

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

# 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]

#2D figure
fig = plt.figure()
fig.add_subplot(1, 1, 1)
plt.title('Orion constellation 2D graphic')
plt.xlabel('Right ascension')
plt.ylabel('Declination')
plt.scatter(x, y, color='red')
plt.show()

#3D figure
fig_3d = plt.figure()
constellation3d = fig_3d.add_subplot(1, 1, 1, projection='3d')
plt.title('Orion constellation 3D graphic')
constellation3d.scatter(x, y, z, color='green')
constellation3d.set_zlabel('Distance')
constellation3d.set_xlabel('Right ascension')
constellation3d.set_ylabel('Declination')
plt.show()

Hope I have not put any label on wrong axes.

1 Like

I think plt.zlabel isn’t included as a wrapper function because most of the plots are designed for 2D and plt.zlabel would be liable to throw errors. Better to leave the labelling to the methods assigned to the 3D object which is good practice in OOP anyway. As for the labels I think you’d need to check the original paper (linked in the .ipynb file), I believe the co-ordinates are converted to Cartesian rather than being left as right angle/declination and distance.

I think I’m quite confused about the Origin coordinate given in the project.

According to this article in Wiki, if I see equator as the X axes, and celestial pole as Y axes, then the “right ascension” is similar to X axes, and “declination” is also like Y axes. So the Z axes can only be the third coordinate which is “distance”.

Also in the project paper 2nd paragraph, it mentioned declination is similar to longitude, and right ascension is known as the “hour angle” which can only be X axes.

I’m not sure what does these coordinate mean in the project, and this is my first time bump into a celestial concept. Quite challenging, but fun.