Can't get the example Plotting in 3D to work
See original GitHub issueBelow is a copy of the example Plotting in 3D. I can run the just fine in Firefox. However, when I copy the code to Jupyter Notebook and attempt to run the same code (shown below), I get the errors below.
Have I missed something? Please advise.
Sam Dupree.
‘’’ #!/Users/user/opt/anaconda3/bin/python
import numpy as np
from poliastro.examples import iss from poliastro.examples import molniya
from poliastro.constants import J2000 from poliastro.examples import * from poliastro.plotting import *
import plotly.io as pio pio.renderers.default = “notebook_connected”
churi.plot(interactive=True, use_3d=True)
frame = OrbitPlotter3D()
frame.plot(churi) frame.plot_body_orbit(Earth, J2000)
frame = OrbitPlotter3D()
frame.plot(molniya) frame.plot(iss)
eros = Orbit.from_sbdb(“eros”)
frame = OrbitPlotter3D()
frame.plot_body_orbit(Earth, J2000) frame.plot(eros, label=“eros”)
from poliastro.ephem import Ephem from poliastro.util import time_range
date_launch = time.Time(“2011-11-26 15:02”, scale=“utc”).tdb date_arrival = time.Time(“2012-08-06 05:17”, scale=“utc”).tdb
earth = Ephem.from_body( Earth, time_range(date_launch, end=date_arrival, periods=50) )
frame = OrbitPlotter3D() frame.set_attractor(Sun)
frame.plot_body_orbit(Earth, J2000, label=Earth) frame.plot_ephem(earth, label=Earth)
ValueError Traceback (most recent call last) <ipython-input-70-cf46d7121b38> in <module> 18 19 frame.plot(churi) —> 20 frame.plot_body_orbit(Earth, J2000) 21 22 frame = OrbitPlotter3D()
~/opt/anaconda3/lib/python3.8/site-packages/poliastro/plotting/core.py in plot_body_orbit(self, body, epoch, label, color, trail) 96 97 “”" —> 98 super().plot_body_orbit(body, epoch, label=label, color=color, trail=trail) 99 100 if not self._figure._in_batch_mode:
~/opt/anaconda3/lib/python3.8/site-packages/poliastro/plotting/_base.py in plot_body_orbit(self, body, epoch, label, color, trail) 265 # Do not return the result of self._plot 266 # This behavior might be overriden by subclasses –> 267 self._plot_body_orbit(body, epoch, label=label, color=color, trail=trail) 268 269 def plot_ephem(self, ephem, epoch=None, *, label=None, color=None, trail=False):
~/opt/anaconda3/lib/python3.8/site-packages/poliastro/plotting/_base.py in _plot_body_orbit(self, body, epoch, label, color, trail) 169 period = get_mean_elements(body, epoch).period 170 –> 171 label = generate_label(epoch, label or str(body)) 172 epochs = time_range( 173 epoch, periods=self._num_points, end=epoch + period, scale=“tdb”
~/opt/anaconda3/lib/python3.8/site-packages/poliastro/plotting/util.py in generate_label(epoch, label) 18 def generate_label(epoch, label): 19 epoch = epoch.copy() —> 20 epoch.out_subfmt = “date_hm” 21 label_ = f"{epoch.iso}" 22 if label:
~/opt/anaconda3/lib/python3.8/site-packages/astropy/time/core.py in out_subfmt(self, val)
620 def out_subfmt(self, val):
621 # Setting the out_subfmt property here does validation of val
–> 622 self._time.out_subfmt = val
623 del self.cache
624
~/opt/anaconda3/lib/python3.8/site-packages/astropy/time/formats.py in out_subfmt(self, subfmt) 181 def out_subfmt(self, subfmt): 182 # Validate subfmt value for this class, raises ValueError if not. –> 183 self._select_subfmts(subfmt) 184 self._out_subfmt = subfmt 185
~/opt/anaconda3/lib/python3.8/site-packages/astropy/time/formats.py in _select_subfmts(cls, pattern) 394 if len(subfmts) == 0 and pattern != ‘*’: 395 if len(cls.subfmts) == 0: –> 396 raise ValueError(f’subformat not allowed for format {cls.name}') 397 else: 398 subfmt_names = [x[0] for x in cls.subfmts]
ValueError: subformat not allowed for format jyear_str ‘’’
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)

Top Related StackOverflow Question
Hi @OrbitalMechanic , thanks for another diligent report! Indeed, as @Yash-10 has pointed out downgrading astropy should fix the issue, until we make a new release. We will do it in the coming weeks hopefully.
Hello @OrbitalMechanic To summarize:
Based on your
pip freezeoutput from an earlier issue, you haveastropy==4.2installed. Just downgrade toastropy==4.0and it should work.This is the most common issue we had in recent times 😃