astroplan
astroplan copied to clipboard
plot_sky error
Every call to the function astroplan.plots.plot_sky
raises an exception.
Even with the tutorial example.
Here a minimal code that triggers the error:
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import astropy.units as u
import astroplan, astroplan.plots, astropy.time
apo = astroplan.Observer.at_site('APO')
vega = astroplan.FixedTarget.from_name('Vega')
observe_time = astropy.time.Time(['2000-03-15 15:30:00'])
astroplan.plots.plot_sky(vega,apo, observe_time)
plt.show()
Expected behaviour: a nice polar plot with the position of Vega. Actual outcome:
Traceback (most recent call last):
File "./plots-10.py", line 12, in <module>
astroplan.plots.plot_sky(vega,apo, observe_time)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/astropy/units/decorators.py", line 234, in wrapper
return_ = wrapped_function(*func_args, **func_kwargs)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/astroplan/plots/sky.py", line 216, in plot_sky
ax.set_thetagrids(range(0, 360, 45), theta_labels)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/matplotlib/projections/polar.py", line 1346, in set_thetagrids
self.set_xticklabels(labels)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 63, in wrapper
return get_method(self)(*args, **kwargs)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 451, in wrapper
return func(*args, **kwargs)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/matplotlib/axis.py", line 1793, in _set_ticklabels
return self.set_ticklabels(labels, minor=minor, **kwargs)
File "/opt/anaconda3/envs/astroplan/lib/python3.8/site-packages/matplotlib/axis.py", line 1714, in set_ticklabels
raise ValueError(
ValueError: The number of FixedLocator locations (8), usually from a call to set_ticks, does not match the number of ticklabels (7).
My working station is running conda 4.8.3
on Debian 10
,
# Name Version Build Channel
astroplan 0.6 py_1 conda-forge
astropy 4.0.1.post1 py38h1e0a361_0 conda-forge
matplotlib-base 3.3.1 py38h91b0d89_1 conda-forge
numpy 1.19.1 py38hbc27379_2 conda-forge
python 3.8.5 h1103e12_5_cpython conda-forge
The error is the same when I use the the current master
branch commit:001a1e123500d96979287db3a817d891cb87bd11
Similar issues reported with upgrade to matplotlib 3.3.x:
https://stackoverflow.com/questions/62953704/valueerror-the-number-of-fixedlocator-locations-5-usually-from-a-call-to-set
edited
Here's the official issue:
https://github.com/matplotlib/matplotlib/pull/17266
I don't have a ton of time to dig into code editing on this unfortunately, at least not for a few days.
But lets' close #469 that just appends a label and try to match up with the preferred matplotlib solution (whatever that is, I didn't really dig too much into it, sorry).
I confirmed that both examples work fine with matplotlib<3.3
.
It looks like this issue was fixed at 7a4c0f3.