# Using Python to create a solar system

If anyone is looking for a fun exercise to flex their fingers…

Using just gravitational attraction between bodies, you can create your own 2D solar system with as many stars and planets as you want. Here's a binary star system with some relatively stable planets

Here's the article, including a detailed step-by-step tutorial, if you want to read more: **[Simulating Orbiting Planets in a Solar System Using Python](thepythoncodingbook.com/2021/0)**

…and there's also a 3D version _(next post)_

# 3D Solar System Using Matplotlib

The 3D version uses for the animation

Here's the article: **[Simulating a 3D Solar System In Python Using Matplotlib](thepythoncodingbook.com/2021/1)**

@s_gruppetta I haven't had a lot of usecases for 3D plotting with Matplotlib and usually stay in the 2D domain, but this a a beautiful showcase of its possibilities. Going to dive into the code, very cool 👍

@walterbogers Thank you. Hope you enjoy it. To be honest, most of the _real-world_ 3D plotting I've needed in the past was static. This is dynamic 3D plotting which, arguably, is less common (although of course it's useful for 4D data!)

@s_gruppetta This kind of dynamic 3D plotting is very useful for illustrating physics concepts like your example here, but in business applications it's indeed much less common and, in general, not necessary (at least in my company). But the fact that it's not used all over the place only enhances the coolness of this example 😉 I will certainly enjoy this!

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.