Project - Orion Constellation

Hello, everyone!
I’d concluded my constellation project - Data Scientist path. I’ll enjoy your feedback"
Thanks!
The code is a Jupyter notebook.

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#SETUP\n",
    "%matplotlib\n",
    "from matplotlib import pyplot as plt\n",
    "from mpl_toolkits.mplot3d import Axes3D\n",
    "\n",
    "\n",
    "# Orion\n",
    "x = [-0.41, 0.57, 0.07, 0.00, -0.29, -0.32,-0.50,-0.23, -0.23]\n",
    "y = [4.12, 7.71, 2.36, 9.10, 13.35, 8.13, 7.19, 13.25,13.43]\n",
    "z = [2.06, 0.84, 1.56, 2.07, 2.36, 1.72, 0.66, 1.25,1.38]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#2D VISUALIZATION\n",
    "fig=plt.figure(figsize=(15,10))\n",
    "fig.add_subplot(1,1,1)\n",
    "plt.scatter(x,y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#3D VISUALIZATION\n",
    "fig_3d=plt.figure(figsize=(15,10))\n",
    "ax1=fig_3d.add_subplot(1,1,1,projection=\"3d\")\n",
    "plt.title('Orion Constellation')\n",
    "constellation3d=ax1.scatter(x,y,z)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using matplotlib backend: Qt5Agg\n"
     ]
    }
   ],
   "source": [
    "#3D VISUALIZATION\n",
    "# Orion\n",
    "x = [-0.41, 0.57, 0.07, 0.00, -0.29, -0.32,-0.50,-0.23, -0.23]\n",
    "y = [4.12, 7.71, 2.36, 9.10, 13.35, 8.13, 7.19, 13.25,13.43]\n",
    "z = [2.06, 0.84, 1.56, 2.07, 2.36, 1.72, 0.66, 1.25,1.38]\n",
    "omicron=[7.195, 14.63, -2.191]\n",
    "alpha_centauri=[-1.643, -1.374, -3.838]\n",
    "proxima_centauri=[-1.539, -1.178, -3.752]\n",
    "ox=[omicron[0]]\n",
    "oy=[omicron[1]]\n",
    "oz=[omicron[2]]\n",
    "x_=[alpha_centauri[0],proxima_centauri[0]]\n",
    "y_=[alpha_centauri[1],proxima_centauri[1]]\n",
    "z_=[alpha_centauri[2],proxima_centauri[2]]\n",
    "fig2=plt.figure(figsize=(10,12))\n",
    "ax=fig2.add_subplot(1,1,1,projection=\"3d\")\n",
    "centauri=ax.scatter(x_,y_,z_)\n",
    "omicron=ax.scatter(ox,oy,oz)\n",
    "orion=ax.scatter(x,y,z)\n",
    "plt.title('Constellations: Orion, Centauri & Omicron')\n",
    "plt.legend(['Centauri','Omicron','Orion'])\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

Hi! welcome to the forums.

is there a github link? or a github gist link?

Hi! Unfortunately, not! Thanks!

Hey everyone,

Not really sure where I should share this, so I’ll just post it here :slight_smile:
This is the Constellation project in the Data Science course, hopefully it can be helpful or interesting in some way.

image

I didn’t know how to add a label on the z-axis, how can I do that? I thought it would be similar to the x- and y- axes.

Thanks,
Zayed

You can create a repository in your GitHub account and upload the Jupyter Notebook there. That way you can have portfolio projects.

1 Like

Here’s the documentation on that: https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.html#mpl_toolkits.mplot3d.axes3d.Axes3D.set_zlabel

You also need to use the scatter method of the 3D axis itself. you can also change the facecolor and remove the gridlines:

fig3d = plt.figure()
ax3D = fig3d.add_subplot(1,1,1, projection="3d")
ax3D.set_facecolor('black')
plt.gca().patch.set_facecolor('grey')
ax3D.grid(False)

You can label the z axis with this:

ax3D.set_xlabel('x coordinates')
ax3D.set_ylabel('y coordinates')
ax3D.set_zlabel('z coordinates')

You can also change the marker and color with these parameters:
ax3D.scatter(x,y,z, c='gold', marker = '*', s= 60)

Here’s one of many articles on this:
https://likegeeks.com/3d-plotting-in-python/

And a previous thread with some of the same info (one of several):
https://discuss.codecademy.com/t/orion-constellation-project/540228

1 Like