Orion Constellation

A few questions:

  1. I wasn’t able to see my graphs using ‘%matplotlib notebook’ so I used inline which works. Why is this the case?
  2. Open-ended question, I am unsure of when or why I am giving something a variable name. I get it in the context of modifying tick marks or changing a specific subplot when theres many, but for this exercise I don’t get why we needed variables for our figures and subplots.
  3. I can’t rotate my 3d image.

It’s been a while since I used Jupyter so I’m afraid I can’t remember any specifics of the options for displaying figures, I would assume that the inability to rotate the 3D image relates to the inline plot as it’s not an interactive option. Sorry that’s not of much use.

As for why you’d often name figures, axes, plots and everything else it’s because matplotlib is Python based and almost entirely object oriented. By adding names to these objects we have access to all their methods and data should we need to alter the plot (you also need to keep references objects to prevent them being garbage collected but matplotlib already stores certain objects so it’s not always obvious what is essential and what isn’t). As per your code some methods don’t have wrapper functions, if you had used plt.scatter() instead of ax.scattter() which directly references your 3D object you would not have a 3D plot at all as plt.scatter() is only a 2D plotting function.

It’s unnecessary to name each and every tick label for example unless you had to repeatedly change them as each object has its own references and “children” but references to figures, axes and plots at the least is often very useful (though technically you can address these objects through the reference to the figure).

You may not notice but the majority of functions such as plots actually call plt.gca() or plt.gcf() (get current axis and get current figure respectively) and then subsequently call the methods of these objects. If you continue using matplotlib you may find yourself using the in-built methods directly yourself as working with multiple figures, axes and plots is greatly simplified when you address them by name (especially is the names are sensible and relate to what you’re plotting).

1 Like