Orion Constellation Project Solution

Here is my solution to the Orion Constellation project. Not sure how to optimize the axes better aside from adjusting the .set_xlimit3d type commands. Open to feedback on how to make this more efficient!

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

Orion coordinates

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]

#create fig and set style to dark_background
fig=plt.figure(figsize=(15,4))
plt.style.use(‘dark_background’)

create fig of x and y coordinates in 2D

plt.subplot(1,3,1)
plt.scatter(x,y,label=‘o’,color=‘yellow’)
plt.xlabel(‘x-position’)
plt.ylabel(‘y-position’)

create fig of x and z coordinates in 2D

plt.subplot(1,3,2)
plt.scatter(x,z,label=‘o’,color=‘yellow’)
plt.xlabel(‘x-position’)
plt.ylabel(‘z-position’)

add title above second subplot (top center)

plt.title(‘The Orion Constellation in 2D’)

create fig of y and z coordinates in 2D

plt.subplot(1,3,3)
plt.scatter(y,z,label=‘o’,color=‘yellow’)
plt.xlabel(‘y-position’)
plt.ylabel(‘z-position’)
plt.show()

Create fig with 3D projection

fig_3d = plt.figure()
import numpy as np
constellation3d=fig_3d.add_subplot(1,1,1,projection=“3d”)
plt.title(‘The Orion Constellation in 3D’)
plt.scatter(x,y,z,color=‘yellow’)

axes_min = min(x+y+z) # minimum coordinate value if you would like to use them for setting axes

(see ax.set_xlim3d, ax.set_ylim3d, ax.set_zlim3d)

axes_max = max(x+y+z) # and the maximum coordinate value

constellation3d.set_xlabel(‘x-position’)
constellation3d.set_ylabel(‘y-position’)
constellation3d.set_zlabel(‘z-position’)
plt.show()
plt.savefig(‘Orion3D.png’)