Codecademy Forums

Data Science: Constellation

Hello!

Here is my take on the orion constellation project.
Any feedback is welcome :slight_smile:

constellation_2D constellation_3D

CODE
#create figure
fig = plt.figure()

#save it to a variable to change colors later
ax = fig.add_subplot(1,1,1)

#plot
plt.scatter(x,y, color=‘white’)

#change background colors
ax = plt.gca()
ax.set_facecolor(‘xkcd:navy’)

#name graph
plt.title(“Orion Constellation 2D”)

#display graph
plt.show()

#save graph
plt.savefig(‘constellation_2D.png’)

#create figure
fig_3d = plt.figure()

#save it to a variable to change colors later
ax3 = fig_3d.add_subplot(1,1,1, projection =‘3d’)

#plot
plt.scatter(x,y,z,color=‘white’)

#change background colors
ax3 = plt.gca()
ax3.set_facecolor(‘xkcd:navy’)
ax3.tick_params(axis=‘x’, colors=‘gray’)
ax3.tick_params(axis=‘y’, colors=‘gray’)
ax3.tick_params(axis=‘z’, colors=‘gray’)

#name graph and change title color to white
title_obj = plt.title(“Orion Constellation 3D”)
plt.getp(title_obj)
plt.getp(title_obj, ‘text’)
plt.setp(title_obj, color=‘white’)

#display graph
plt.show()

#save graph
plt.savefig(‘constellation_3D.png’)

1 Like