Basic example fails during plotting
See original GitHub issue🐞 In jupyter, the following
from astropy import units as u
from poliastro.bodies import Earth, Mars, Sun
from poliastro.twobody import Orbit
# Data from Curtis, example 4.3
r = [-6045, -3490, 2500] * u.km
v = [-3.457, 6.618, 2.533] * u.km / u.s
orb = Orbit.from_vectors(Earth, r, v)
orb.plot()
gives an error, which seems to occur regardless of whether jupyter has the plotly extension installed or not.
The traceback is:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-5338537cc405> in <module>
----> 1 orb.plot()
~/opt/anaconda3/envs/astro/lib/python3.8/site-packages/poliastro/twobody/orbit.py in plot(self, label, use_3d, interactive)
1433 from poliastro.plotting.static import StaticOrbitPlotter
1434
-> 1435 return StaticOrbitPlotter().plot(self, label=label)
1436 elif use_3d:
1437 from poliastro.plotting.core import OrbitPlotter3D
~/opt/anaconda3/envs/astro/lib/python3.8/site-packages/poliastro/plotting/static.py in plot(self, orbit, label, color, trail)
213 self.set_orbit_frame(orbit)
214
--> 215 lines = self._plot(orbit, label=label, color=color, trail=trail)
216 lines = lines[0] + [lines[1]]
217
~/opt/anaconda3/envs/astro/lib/python3.8/site-packages/poliastro/plotting/_base.py in _plot(self, orbit, label, color, trail)
151 orbit = orbit.change_plane(self.plane)
152
--> 153 label = generate_label(orbit.epoch, label)
154 coordinates = orbit.sample(self._num_points)
155
~/opt/anaconda3/envs/astro/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/envs/astro/lib/python3.8/site-packages/astropy/time/core.py in out_subfmt(self, val)
849 def out_subfmt(self, val):
850 # Setting the out_subfmt property here does validation of ``val``
--> 851 self._time.out_subfmt = val
852 del self.cache
853
~/opt/anaconda3/envs/astro/lib/python3.8/site-packages/astropy/time/formats.py in out_subfmt(self, subfmt)
179 def out_subfmt(self, subfmt):
180 # Validate subfmt value for this class, raises ValueError if not.
--> 181 self._select_subfmts(subfmt)
182 self._out_subfmt = subfmt
183
~/opt/anaconda3/envs/astro/lib/python3.8/site-packages/astropy/time/formats.py in _select_subfmts(cls, pattern)
387 if len(subfmts) == 0 and pattern != '*':
388 if len(cls.subfmts) == 0:
--> 389 raise ValueError(f'subformat not allowed for format {cls.name}')
390 else:
391 subfmt_names = [x[0] for x in cls.subfmts]
ValueError: subformat not allowed for format jyear_str
🖥 Please paste the output of following commands
conda info -a(only if you have conda)conda list(only if you have conda)pip freeze
active environment : astro
active env location : /Users/juno/opt/anaconda3/envs/astro
shell level : 3
user config file : /Users/juno/.condarc
populated config files : /Users/juno/.condarc
conda version : 4.8.2
conda-build version : 3.18.11
python version : 3.7.6.final.0
virtual packages : __osx=10.15.6
base environment : /Users/juno/opt/anaconda3 (writable)
channel URLs : https://conda.anaconda.org/conda-forge/osx-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/juno/opt/anaconda3/pkgs
/Users/juno/.conda/pkgs
envs directories : /Users/juno/opt/anaconda3/envs
/Users/juno/.conda/envs
platform : osx-64
user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Darwin/19.6.0 OSX/10.15.6
UID:GID : 505:20
netrc file : None
offline mode : False
# conda environments:
#
/Users/juno/.julia/conda/3
base /Users/juno/opt/anaconda3
astro * /Users/juno/opt/anaconda3/envs/astro
beast-env /Users/juno/opt/anaconda3/envs/beast-env
/usr/local/anaconda3
sys.version: 3.7.6 (default, Jan 8 2020, 13:42:34)
...
sys.prefix: /Users/juno/opt/anaconda3
sys.executable: /Users/juno/opt/anaconda3/bin/python
conda location: /Users/juno/opt/anaconda3/lib/python3.7/site-packages/conda
conda-build: /Users/juno/opt/anaconda3/bin/conda-build
conda-convert: /Users/juno/opt/anaconda3/bin/conda-convert
conda-debug: /Users/juno/opt/anaconda3/bin/conda-debug
conda-develop: /Users/juno/opt/anaconda3/bin/conda-develop
conda-env: /Users/juno/opt/anaconda3/bin/conda-env
conda-index: /Users/juno/opt/anaconda3/bin/conda-index
conda-inspect: /Users/juno/opt/anaconda3/bin/conda-inspect
conda-metapackage: /Users/juno/opt/anaconda3/bin/conda-metapackage
conda-render: /Users/juno/opt/anaconda3/bin/conda-render
conda-server: /Users/juno/opt/anaconda3/bin/conda-server
conda-skeleton: /Users/juno/opt/anaconda3/bin/conda-skeleton
conda-verify: /Users/juno/opt/anaconda3/bin/conda-verify
user site dirs:
CIO_TEST: <not set>
CONDA_DEFAULT_ENV: astro
CONDA_EXE: /Users/juno/opt/anaconda3/bin/conda
CONDA_PREFIX: /Users/juno/opt/anaconda3/envs/astro
CONDA_PREFIX_1: /Users/juno/opt/anaconda3
CONDA_PREFIX_2: /Users/juno/opt/anaconda3/envs/beast-env
CONDA_PROMPT_MODIFIER: (astro)
CONDA_PYTHON_EXE: /Users/juno/opt/anaconda3/bin/python
CONDA_ROOT: /Users/juno/opt/anaconda3
CONDA_SHLVL: 3
PATH: /Users/juno/opt/anaconda3/bin:/Users/juno/opt/anaconda3/envs/astro/bin:/Users/juno/opt/anaconda3/condabin:/usr/local/opt/openjdk/bin:/usr/local/texlive/2019/bin/x86_64-darwin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
# packages in environment at /Users/juno/opt/anaconda3/envs/astro:
#
# Name Version Build Channel
appnope 0.1.0 py38h32f6830_1002 conda-forge
argon2-cffi 20.1.0 py38h4d0b108_2 conda-forge
astropy 4.1 py38h4d0b108_0 conda-forge
astroquery 0.4.1 pyh9f0ad1d_0 conda-forge
async_generator 1.10 py_0 conda-forge
attrs 20.2.0 pyh9f0ad1d_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
backports 1.0 py_2 conda-forge
backports.functools_lru_cache 1.6.1 py_0 conda-forge
beautifulsoup4 4.9.3 pyhb0f4dca_0 conda-forge
bleach 3.2.1 pyh9f0ad1d_0 conda-forge
brotlipy 0.7.0 py38h94c058a_1001 conda-forge
ca-certificates 2020.6.20 hecda079_0 conda-forge
cached-property 1.5.1 py_0 conda-forge
certifi 2020.6.20 py38h5347e94_2 conda-forge
cffi 1.14.3 py38h9edaa1b_1 conda-forge
chardet 3.0.4 py38h5347e94_1008 conda-forge
cryptography 3.1.1 py38h52adbb4_0 conda-forge
cycler 0.10.0 py_2 conda-forge
decorator 4.4.2 py_0 conda-forge
defusedxml 0.6.0 py_0 conda-forge
entrypoints 0.3 py38h32f6830_1002 conda-forge
freetype 2.10.4 ha233b18_0 conda-forge
html5lib 1.1 pyh9f0ad1d_0 conda-forge
icu 67.1 hb1e8313_0 conda-forge
idna 2.10 pyh9f0ad1d_0 conda-forge
importlib-metadata 2.0.0 py_1 conda-forge
importlib_metadata 2.0.0 1 conda-forge
ipykernel 5.3.4 py38h1cdfbd6_1 conda-forge
ipython 7.18.1 py38h1cdfbd6_1 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
jedi 0.17.2 py38h32f6830_1 conda-forge
jinja2 2.11.2 pyh9f0ad1d_0 conda-forge
jpeg 9d h0b31af3_0 conda-forge
jplephem 2.15 pyh2f6353c_0 conda-forge
jsonschema 3.2.0 py_2 conda-forge
jupyter_client 6.1.7 py_0 conda-forge
jupyter_core 4.6.3 py38h32f6830_2 conda-forge
jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge
keyring 21.4.0 py38h32f6830_2 conda-forge
kiwisolver 1.2.0 py38h02bb52f_1 conda-forge
lcms2 2.11 h174193d_0 conda-forge
libblas 3.9.0 2_openblas conda-forge
libcblas 3.9.0 2_openblas conda-forge
libcxx 11.0.0 h439d374_0 conda-forge
libffi 3.2.1 hb1e8313_1007 conda-forge
libgfortran 5.0.0 h7cc5361_13 conda-forge
libgfortran5 9.3.0 h7cc5361_13 conda-forge
liblapack 3.9.0 2_openblas conda-forge
libllvm8 8.0.1 h770b8ee_0 conda-forge
libopenblas 0.3.12 openmp_h54245bb_1 conda-forge
libpng 1.6.37 hb0a8c7a_2 conda-forge
libsodium 1.0.18 haf1e3a3_1 conda-forge
libtiff 4.1.0 h2ae36a8_6 conda-forge
libuv 1.40.0 h22f3db7_0 conda-forge
libwebp-base 1.1.0 h0b31af3_3 conda-forge
llvm-openmp 11.0.0 h73239a0_1 conda-forge
llvmlite 0.31.0 py38h0d43c1d_1 conda-forge
lz4-c 1.9.2 hb1e8313_3 conda-forge
markupsafe 1.1.1 py38h94c058a_2 conda-forge
matplotlib-base 3.3.2 py38had0acaf_1 conda-forge
mistune 0.8.4 py38h4d0b108_1002 conda-forge
nbclient 0.5.1 py_0 conda-forge
nbconvert 6.0.7 py38h32f6830_1 conda-forge
nbformat 5.0.8 py_0 conda-forge
ncurses 6.2 hb1e8313_2 conda-forge
nest-asyncio 1.4.1 py_0 conda-forge
nodejs 14.14.0 hdde0ff8_0 conda-forge
notebook 6.1.4 py38h32f6830_1 conda-forge
numba 0.48.0 py38h4f17bb1_0 conda-forge
numpy 1.19.2 py38ha98150c_1 conda-forge
olefile 0.46 pyh9f0ad1d_1 conda-forge
openssl 1.1.1h haf1e3a3_0 conda-forge
packaging 20.4 pyh9f0ad1d_0 conda-forge
pandas 1.1.3 py38h48ddb8e_2 conda-forge
pandoc 2.11.0.4 h22f3db7_0 conda-forge
pandocfilters 1.4.2 py_1 conda-forge
parso 0.7.1 pyh9f0ad1d_0 conda-forge
pexpect 4.8.0 pyh9f0ad1d_2 conda-forge
pickleshare 0.7.5 py_1003 conda-forge
pillow 8.0.1 py38hef457fe_0 conda-forge
pip 20.2.4 py_0 conda-forge
plotly 4.12.0 pyh9f0ad1d_0 conda-forge
poliastro 0.14.0 py_1 conda-forge
prometheus_client 0.8.0 pyh9f0ad1d_0 conda-forge
prompt-toolkit 3.0.8 py_0 conda-forge
ptyprocess 0.6.0 py_1001 conda-forge
pycparser 2.20 pyh9f0ad1d_2 conda-forge
pygments 2.7.2 py_0 conda-forge
pyopenssl 19.1.0 py_1 conda-forge
pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge
pyrsistent 0.17.3 py38h4d0b108_1 conda-forge
pysocks 1.7.1 py38h5347e94_2 conda-forge
python 3.8.6 hcfdab8c_0_cpython conda-forge
python-dateutil 2.8.1 py_0 conda-forge
python_abi 3.8 1_cp38 conda-forge
pytz 2020.1 pyh9f0ad1d_0 conda-forge
pyzmq 19.0.2 py38h2c785a9_2 conda-forge
readline 8.0 h0678c8f_2 conda-forge
requests 2.24.0 pyh9f0ad1d_0 conda-forge
retrying 1.3.3 py_2 conda-forge
scipy 1.5.2 py38h2a334b3_2 conda-forge
send2trash 1.5.0 py_0 conda-forge
setuptools 49.6.0 py38h5347e94_2 conda-forge
six 1.15.0 pyh9f0ad1d_0 conda-forge
soupsieve 2.0.1 py_1 conda-forge
sqlite 3.33.0 h960bd1c_1 conda-forge
terminado 0.9.1 py38h32f6830_1 conda-forge
testpath 0.4.4 py_0 conda-forge
tk 8.6.10 hb0a8c7a_1 conda-forge
tornado 6.0.4 py38h4d0b108_2 conda-forge
traitlets 5.0.5 py_0 conda-forge
urllib3 1.25.11 py_0 conda-forge
wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge
webencodings 0.5.1 py_1 conda-forge
wheel 0.35.1 pyh9f0ad1d_0 conda-forge
xz 5.2.5 haf1e3a3_1 conda-forge
zeromq 4.3.3 hb1e8313_2 conda-forge
zipp 3.4.0 py_0 conda-forge
zlib 1.2.11 h7795811_1010 conda-forge
zstd 1.4.5 h289c70a_2 conda-forge
appnope @ file:///Users/runner/miniforge3/conda-bld/appnope_1602242458663/work
argon2-cffi @ file:///Users/runner/miniforge3/conda-bld/argon2-cffi_1602546574518/work
astropy @ file:///Users/runner/miniforge3/conda-bld/astropy_1603485167278/work
astroquery==0.4.1
async-generator==1.10
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1599308529326/work
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache==1.6.1
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1601745390275/work
bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1600454382015/work
brotlipy==0.7.0
cached-property==1.5.1
certifi==2020.6.20
cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1602537245790/work
chardet @ file:///Users/runner/miniforge3/conda-bld/chardet_1602255309528/work
cryptography @ file:///Users/runner/miniforge3/conda-bld/cryptography_1600960179663/work
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
entrypoints @ file:///Users/runner/miniforge3/conda-bld/entrypoints_1602701742773/work/dist/entrypoints-0.3-py2.py3-none-any.whl
html5lib @ file:///home/conda/feedstock_root/build_artifacts/html5lib_1592930327044/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1593328102638/work
importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1602263269022/work
ipykernel @ file:///Users/runner/miniforge3/conda-bld/ipykernel_1602682896422/work/dist/ipykernel-5.3.4-py3-none-any.whl
ipython @ file:///Users/runner/miniforge3/conda-bld/ipython_1602640419216/work
ipython-genutils==0.2.0
jedi @ file:///Users/runner/miniforge3/conda-bld/jedi_1602395236037/work
Jinja2==2.11.2
jplephem @ file:///home/conda/feedstock_root/build_artifacts/jplephem_1599086171188/work
jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema_1602551949684/work
jupyter-client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1598486169312/work
jupyter-core @ file:///Users/runner/miniforge3/conda-bld/jupyter_core_1602537297490/work
jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1601375948261/work
keyring @ file:///Users/runner/miniforge3/conda-bld/keyring_1602701122678/work
kiwisolver @ file:///Users/runner/miniforge3/conda-bld/kiwisolver_1602517227315/work
llvmlite==0.31.0
MarkupSafe @ file:///Users/runner/miniforge3/conda-bld/markupsafe_1602267327822/work
matplotlib @ file:///Users/runner/miniforge3/conda-bld/matplotlib-suite_1602600871595/work
mistune @ file:///Users/runner/miniforge3/conda-bld/mistune_1602381756020/work
nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1602859080374/work
nbconvert @ file:///Users/runner/miniforge3/conda-bld/nbconvert_1602715415880/work
nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1602732862338/work
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1601342677072/work
notebook @ file:///Users/runner/miniforge3/conda-bld/notebook_1602720147128/work
numba==0.48.0
numpy @ file:///Users/runner/miniforge3/conda-bld/numpy_1603047582194/work
olefile @ file:///home/conda/feedstock_root/build_artifacts/olefile_1602866521163/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1589925210001/work
pandas==1.1.3
pandocfilters==1.4.2
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1595548966091/work
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow @ file:///Users/runner/miniforge3/conda-bld/pillow_1603406624790/work
plotly @ file:///home/conda/feedstock_root/build_artifacts/plotly_1603467793398/work
poliastro @ file:///home/conda/feedstock_root/build_artifacts/poliastro_1588955814446/work
prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1590412252446/work
prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1602524994744/work
ptyprocess==0.6.0
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1593275161868/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1603558917696/work
pyOpenSSL==19.1.0
pyparsing==2.4.7
pyrsistent @ file:///Users/runner/miniforge3/conda-bld/pyrsistent_1602259983752/work
PySocks @ file:///Users/runner/miniforge3/conda-bld/pysocks_1602326916036/work
python-dateutil==2.8.1
pytz==2020.1
pyzmq==19.0.2
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1592425495151/work
retrying==1.3.3
scipy @ file:///Users/runner/miniforge3/conda-bld/scipy_1603636253193/work
Send2Trash==1.5.0
six @ file:///home/conda/feedstock_root/build_artifacts/six_1590081179328/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1597680516047/work
terminado @ file:///Users/runner/miniforge3/conda-bld/terminado_1602679604944/work
testpath==0.4.4
tornado @ file:///Users/runner/miniforge3/conda-bld/tornado_1602488900263/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1602771532708/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1603125704209/work
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work
webencodings==0.5.1
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1603668650351/work
💡 Possible solutions
📋 Steps to solve the problem
I’m a total noob to poliastro, so I’m not really sure where to start with this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error plot graphs - JpGraph
Error plots are used to visually indicate uncertainty in data points. This is done by specifying both a min and and max value...
Read more >R Error: plot.new has not been called yet (2 Examples)
How to solve the error “ plot.new has not been called yet” in the R programming language.
Read more >R How to Fix: Error in plot.new() : figure margins too large ...
R How to Fix: Error in plot.new() : figure margins too large ( Examples ) | Change Plot Area | par mar.
Read more >simple example using Plots following with warnings and an error
I am using Julia 0.6.2 (Windows) and the Atom editor After launching Julia and using Plots I've got the following warnings: WARNING: using...
Read more >Problem with Plots or Graphics Device in the RStudio IDE
1) "Error in plot.new() : figure margins too large" · 2) Graphic with missing or distorted components · 3) Reset your graphics device....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ah, right, forgot the
plt.show(), good call.Thanks, works for me now!
Good news! It was fixed on https://github.com/poliastro/poliastro/pull/1019 then. We’ll have a new poliastro release before the end of the year, make sure you subscribe to the project releases to get notified! I’m closing this issue, since it’s not present on
master.Try
import matplotlib.pyplot as pltandplt.show()afterorb.plot(), and if that doesn’t work please open a new issue 😃