8000 Issue with SpeasyVariable.plot() · Issue #59 · SciQLop/speasy · GitHub
[go: up one dir, main page]

Skip to content
Issue with SpeasyVariable.plot() #59
@cmoissar

Description

@cmoissar
  • Space Physics WebServices Client version: Not sure what you mean
  • Python version: 3.10.6
  • Operating System: Ubuntu

Description

Reproduce AMDA First Steps.

What I Did

Copy and paste the first steps from the link above.

Output:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_17102/2607499050.py in <module>
      1 plt.figure()
      2 ace_mag = spz.get_data(amda_tree.Parameters.ACE.MFI.ace_imf_all.imf, datetime(2016,6,2), datetime(2016,6,5))
----> 3 ace_mag.plot()
      4 plt.tight_layout()
      5 plt.show()

~/.local/lib/python3.10/site-packages/speasy/plotting/__init__.py in __call__(self, backend, *args, **kwargs)
     69         if self._infer_plot_type() == PlotType.SPECTRO:
     70             return self.colormap(backend=backend, *args, **kwargs)
---> 71         return self.line(backend=backend, *args, **kwargs)
     72 
     73     def __getitem__(self, item):

~/.local/lib/python3.10/site-packages/speasy/plotting/__init__.py in line(self, backend, *args, **kwargs)
     46         units = self.values.unit
     47         yaxis_label = self.values.name
---> 48         return self._get_backend(backend).line(x=self.axes[0].values, y=self.values, labels=self.columns_names,
     49                                                units=units,
     50                                                xaxis_label=self.axes[0].name,

~/.local/lib/python3.10/site-packages/speasy/plotting/mpl_backend/__init__.py in line(self, x, y, ax, labels, units, xaxis_label, yaxis_label, *args, **kwargs)
     20         ax = self._get_ax(ax)
     21         ax.tick_params(axis='x', labelrotation = 45)
---> 22         ax.plot(x, y)
     23         if labels is not None:
     24             ax.legend(labels)

/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
   1630         """
   1631         kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
-> 1632         lines = [*self._get_lines(*args, data=data, **kwargs)]
   1633         for line in lines:
   1634             self.add_line(line)

/usr/lib/python3/dist-packages/matplotlib/axes/_base.py in __call__(self, data, *args, **kwargs)
    310                 this += args[0],
    311                 args = args[1:]
--> 312             yield from self._plot_args(this, kwargs)
    313 
    314     def get_next_color(self):

/usr/lib/python3/dist-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs, retur
6922
n_kwargs)
    486         if len(xy) == 2:
    487             x = _check_1d(xy[0])
--> 488             y = _check_1d(xy[1])
    489         else:
    490             x, y = index_of(xy[-1])

/usr/lib/python3/dist-packages/matplotlib/cbook/__init__.py in _check_1d(x)
   1325                     message='Support for multi-dimensional indexing')
   1326 
-> 1327                 ndim = x[:, None].ndim
   1328                 # we have definitely hit a pandas index or series object
   1329                 # cast to a numpy array.

AttributeError: 'DataContainer' object has no attribute 'ndim'

Summary

Everything works great and I really wish I had access to such a great tool 5 years ago at the start of my PhD.
But the .plot() function a speasy.products.variable.SpeasyVariable doesn't seem to work on my laptop. Is it only me?

Best wishes,
Clement

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0