We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When an axis is passed to NDCube.plot, an UnboundLocalErrror is thrown. This appears to be because ax is never actually set if axes is not None in _plot_2D_cube
NDCube.plot
UnboundLocalErrror
ax
axes
_plot_2D_cube
A 2D plot.
--------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) <ipython-input-50-663bc3b9d2f3> in <module> 1 fig = plt.figure() 2 ax = fig.gca(projection=m) ----> 3 c.plot(**m.plot_settings,axes=ax) ~/anaconda/envs/sunkit-dem/lib/python3.7/site-packages/ndcube/mixins/plotting.py in plot(self, axes, plot_axis_indices, axes_coordinates, axes_units, data_unit, **kwargs) 81 if naxis == 2: 82 ax = self._plot_2D_cube(axes, plot_axis_indices, axes_coordinates, ---> 83 axes_units, data_unit, **kwargs) 84 else: 85 ax = self._plot_3D_cube( ~/anaconda/envs/sunkit-dem/lib/python3.7/site-packages/ndcube/mixins/plotting.py in _plot_2D_cube(self, axes, plot_axis_indices, axes_coordinates, axes_units, data_unit, **kwargs) 263 ax.set_xlabel(xlabel) 264 ax.set_ylabel(ylabel) --> 265 return ax 266 267 def _plot_3D_cube(self, plot_axis_indices=None, axes_coordinates=None, UnboundLocalError: local variable 'ax' referenced before assignment
import sunpy.data.sample import ndcube import matplotlib.pyplot as plt m = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE) c = ndcube.NDCube(m.data,m.wcs) fig = plt.figure() ax = fig.gca(projection=m) c.plot(**m.plot_settings,axes=ax)
The text was updated successfully, but these errors were encountered:
Thanks @wtbarnes. Can you by any chance revert to ndcube 1.1.2 and confirm the same behaviour is produced?
Sorry, something went wrong.
Yep, this error pops up in v1.1.2 as well
OK, thanks. We'll add it to the next milestone.
Add test for sunpy#192
f11eef9
Refactor plot_2D to fix sunpy#192
d424046
Cadair
Successfully merging a pull request may close this issue.
Description
When an axis is passed to
NDCube.plot
, anUnboundLocalErrror
is thrown. This appears to be becauseax
is never actually set ifaxes
is not None in_plot_2D_cube
Expected behavior
A 2D plot.
Actual behavior
Steps to Reproduce
System Details
The text was updated successfully, but these errors were encountered: