Orion-Constellation Project

Hi everyone! I’ve just completed the Orion Constellation Project on Jupiter Notebook. The following is my code (As a new user, I cannot upload more than one jpg image so I’ve put both the plots in at the end!)

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

x, y, x coordinates for each star in the constellation

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]

#Creating a 2D visualization
fig=plt.figure()
ax = plt.subplot(1, 1, 1)
plt.scatter(x, y, color=‘red’, alpha=0.5)
plt.title(“2D Visualization of the Orion Constellation”)
plt.show(fig)

#Creating a 3D visualization
fig_3d = plt.figure()
fig_3d.add_subplot(1,1,1,projection=“3d”)
constellation3d = plt.scatter(x,y,z, color=‘red’)
plt.title(“3D Visualization of the Orion Constellation”)
plt.show()

I cannot seem to be able to figure out how to change the marker size. I’ve tried putting in plt.scatter(x, y, z, s=30) but the plot doesn’t show up at all. Any help would be appreciated!

This one has come up recently and it’s an issue with using the standard matplotlib.pyplot.scatter function which is a 2D scatter function (all those points are on the same xy plane at z=0.0). You need to be using the scatter method of the 3d axis itself, e.g. ax3d.scatter(x, y, z, s=30, marker... etc.). See the docs for info-
https://matplotlib.org/3.3.0/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.html#mpl_toolkits.mplot3d.axes3d.Axes3D.scatter

1 Like