# 3D Earth and Celestial Bodies#

Plot the solar system in PyVista.

This example is inspired by planet3D-MATLAB.

Note

The purpose of this example is to demonstrate plotting celestial bodies and may lack astronomical precision. There may be inaccuracies in the representation, so please take care when reusing or repurposing this example.

Please take a look at libraries like astropy if you wish to use Python for astronomical calculations.

```from __future__ import annotations

import pyvista
from pyvista import examples
```

# Plot the Solar System with Stars in the Background#

This section relies on calculations in Visualizing Celestial Bodies in 3D.

```# Light of the Sun.
light = pyvista.Light()
light.set_direction_angle(30, -20)

# Saturn's rings range from 7000.0 km to 80000.0 km from the surface of the planet
inner = 60268.0 + 7000.0
outer = 60268.0 + 80000.0

# Move planets to a nice position for the plotter. These numbers are not
# grounded in reality and are for demonstration purposes only.
mercury.translate((0.0, 0.0, 0.0), inplace=True)
venus.translate((-15000.0, 0.0, 0.0), inplace=True)
earth.translate((-30000.0, 0.0, 0.0), inplace=True)
mars.translate((-45000.0, 0.0, 0.0), inplace=True)
jupiter.translate((-150000.0, 0.0, 0.0), inplace=True)
saturn.translate((-400000.0, 0.0, 0.0), inplace=True)
saturn_rings.translate((-400000.0, 0.0, 0.0), inplace=True)
uranus.translate((-600000.0, 0.0, 0.0), inplace=True)
neptune.translate((-700000.0, 0.0, 0.0), inplace=True)

pl = pyvista.Plotter(lighting="none")
pl.set_environment_texture(cubemap, True)
pl.show()
```

# Plot the Planets and their Textures#

Each planet here is in a different subplot. The planet’s textures are from Solar Textures.

```pl = pyvista.Plotter(shape=(3, 2))
pl.subplot(0, 0)
pl.subplot(0, 1)
pl.subplot(1, 0)
pl.subplot(1, 1)
pl.subplot(2, 0)
pl.subplot(2, 1)
pl.show(cpos="xy")
```

# Plot the Atmosphere and Surface of Venus#

Here we plot Venus with and without its atmosphere.

```venus = examples.planets.load_venus()

pl = pyvista.Plotter(shape=(1, 2))
pl.subplot(0, 0)