holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.7k stars 403 forks source link

Chart3D from Tutorials/Elements not working in example #90

Closed basnijholt closed 9 years ago

basnijholt commented 9 years ago

I've tried

%load_ext holoviews.ipython
import numpy as np
from holoviews import Surface
%%opts Surface [figure_size=125] (cmap='jet' rstride=20, cstride=2)
Surface(np.sin(np.linspace(0,100*np.pi*2,10000)).reshape(100,100))

and

%%opts Scatter3D [azimuth=40 elevation=20]
x,y = np.mgrid[-5:5, -5:5] * 0.1
heights = np.sin(x**2+y**2)
Scatter3D(zip(x.flat,y.flat,heights.flat))

both don't work

jlstevens commented 9 years ago

Does the code generate a traceback? Or does nothing happen at all?

It is difficult to diagnose what is going wrong without knowing what happens when you run the code mentioned above.

philippjfr commented 9 years ago

Yea I just checked and it's still working fine on my end and on the machine that builds the docs for us. I don't really think this is it, since I think matplotlib ships with the 3d toolkit now but could you try this import as well:

from mpl_toolkits.mplot3d import Axes3D

A traceback would be helpful too.

basnijholt commented 9 years ago

Ah, I thought it wouldn't work for anyone. But I tried on my own laptop and there it works.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/holoviews/ipython/display_hooks.py", line 212, in wrapped
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/holoviews/ipython/display_hooks.py", line 241, in element_display
    fig = Store.registry[element.__class__](element, **opts(element, size))()
  File "/usr/local/lib/python2.7/dist-packages/holoviews/plotting/element.py", line 132, in __init__
    uniform=uniform, **dict(params, **plot_opts))
  File "/usr/local/lib/python2.7/dist-packages/holoviews/plotting/plot.py", line 132, in __init__
    self.handles['axis'] = self._init_axis(axis)
  File "/usr/local/lib/python2.7/dist-packages/holoviews/plotting/plot.py", line 289, in _init_axis
    axis = fig.add_subplot(111, projection=self.projection)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 964, in add_subplot
    a = subplot_class_factory(projection_class)(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_subplots.py", line 78, in __init__
    self._axes_class.__init__(self, fig, self.figbox, **kwargs)
  File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py", line 91, in __init__
    *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 437, in __init__
    self.cla()
  File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py", line 1045, in cla
    Axes.cla(self)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 908, in cla
    self.grid(self._gridOn, which=rcParams['axes.grid.which'])
  File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py", line 1256, in grid
    self._draw_grid = maxes._string_to_bool(b)
AttributeError: 'module' object has no attribute '_string_to_bool'
:Surface   [x,y]   (z)

from mpl_toolkits.mplot3d import Axes3D doesn't help.

philippjfr commented 9 years ago

Have a look at this Stackoverflow question.

Edit: It's probably caused by an old matplotlib version installed into the system site-packages, which is overriding the local version in your virtual environment. Try either deleting or renaming the system-wide matplotlib or simply renaming the mplot3d toolkit in the system mpl_toolkits.

philippjfr commented 9 years ago

Closing this as it is not a bug in HoloViews.

basnijholt commented 9 years ago

Of course, thanks, I'll try :)

jlstevens commented 9 years ago

I wonder if there is some way we could check matplotlib installs before people try to use HoloViews features. I realize this is fanciful but if we could tell users to try something like:

from holoviews.utils import test_matplotlib
test_matplotlib()

Then that would be a good way to know what is due to holoviews and what is due to the matplotlib install. Again, I realize this probably isn't feasible!

github-actions[bot] commented 1 week ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.