Codecademy Forums

Project: Visualizing the Orion Constellation

Hej!

Below my code, which is work well when running from bash >>python constellation.py. Rotation is working. But it wasn’t successful to rotate the figures in jupyter notebook or google colab.

The code:

#!/usr/bin/env python

#%matplotlib notebook
#the code used through bash in linux so the %matplotlib notebook is not needed to rotate the figure
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

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]

#constellation2d
fig = plt.figure()
fig2d = fig.add_subplot(1,1,1)
fig2d.scatter(x,y, color = ‘black’)
plt.title(‘2D Orion Constellation’)
plt.show()

#constellation3d
fig = plt.figure()
fig_3d = fig.add_subplot(1,1,1,projection=“3d”)
fig_3d.scatter(x,y,z)
plt.title(‘Orion Constellation’)
plt.show()