#
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]
# Create 2D Visualization
fig = plt.figure(figsize=(6,5))
fig.add_subplot(1,1,1)
plt.scatter(x,y, color="green")
plt.xlabel("Cartesian X distance. Hundreds Light Years")
plt.ylabel("Cartesian Y distance. Hundreds Light Years")
plt.title("2D Visualization of Orion Constellation")
plt.show()
# Create 3D Visualization
fig_3d = plt.figure(figsize=(6,5)).add_subplot(1,1,1, projection="3d")
fig_3d.scatter(x,y,z, color="green")
fig_3d.set_xlabel("Hundreds Light Years (X)")
fig_3d.set_ylabel("Hundreds Light Years (Y)")
fig_3d.set_zlabel("Hundreds Light Years (Z)")
fig_3d.set_title("3D Visualization of Orion Constellation")
plt.show()
Congrats on finishing the project.
Just a thought…for the 3d plot, you could also try adding the maker parameter, s parameter, getting rid of the grid and making the background black like so:
fig_3d.scatter(x,y,z, color="gold", marker = '*', s=60)
fig_3d.set_facecolor('black')
fig_3d.grid(False)
https://matplotlib.org/stable/tutorials/toolkits/mplot3d.html
Hi el_friend,
Well done! All the code looks good, and below is my feedback based on the rubric for this project.
Matplotlib and CSV - 4 / 4
Implementation of 2D visualization - 4 / 4
Implementation of 3D visualization - 4 / 4
Regards,
Thiago
1 Like