question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get the example Plotting in 3D to work

See original GitHub issue

Below 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:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
astrojuanlucommented, Apr 3, 2021

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.

1reaction
Yash-10commented, Mar 31, 2021

Hello @OrbitalMechanic To summarize:

Based on yourpip freeze output from an earlier issue, you have astropy==4.2 installed. Just downgrade to astropy==4.0 and it should work.

This is the most common issue we had in recent times 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with 3d plots - MATLAB Answers - MathWorks
Hi, I have a issue with mesh and surface commands. I'm not getting 3d plots, instead of that only 2d plots are coming ......
Read more >
3D Plotting in Matlab - YouTube
This tutorial illustrates how to generate 3D plots in Matlab. We investigate the concept of how to generate a discrete representation of a ......
Read more >
Plotting a 3D graph in Excel - YouTube
Screencast showing how to plot a 3D graph in Excel. Steps to plot x-y-z data, changing the position ... Your browser can't play...
Read more >
matplotlib 3d surface plots not showing [duplicate]
I am trying to make a simple 3D surface plot with matplotlib but the plot does not show at the end; I only...
Read more >
Three-Dimensional Plotting in Matplotlib
Three-dimensional plotting is one of the functionalities that benefits immensely from viewing figures interactively rather than statically in the notebook; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found