hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

Error when setting aspect to 'auto'

Open maximlt opened this issue 9 months ago • 0 comments

Recording an issue we found when documenting aspect. Very likely a HoloViews issue but I wanted to record it here first before I forget.

import hvplot.pandas
import hvsampledata

df = hvsampledata.penguins("pandas")

plot = df.hvplot.scatter("bill_length_mm", "bill_depth_mm", aspect="auto")
hvplot.render(plot)
TypeError: '>' not supported between instances of 'str' and 'int'

Traceback (most recent call last):
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 742, in _axis_props
    l, b, r, t = self.get_extents(range_el, ranges, dimension=dim)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 1502, in get_extents
    range_extents = self._get_range_extents(element, ranges, range_type, xdim, ydim, zdim)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 1413, in _get_range_extents
    xpad, ypad, zpad = self.get_padding(element, (x0, y0, z0, x1, y1, z1))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 1380, in get_padding
    if aspect > 1:
       ^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mliquet/dev/hvplot/.mltmess/issue_aspect_equal.py", line 7, in <module>
    hvplot.render(plot)
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/util/__init__.py", line 880, in render
    return renderer_obj.get_plot_state(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/renderer.py", line 273, in get_plot_state
    obj = self_or_cls.get_plot(obj=obj, renderer=renderer, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/bokeh/renderer.py", line 70, in get_plot
    plot = super().get_plot(obj, doc, renderer, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/renderer.py", line 239, in get_plot
    plot.update(init_key)
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 958, in update
    return self.initialize_plot()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 2181, in initialize_plot
    plot = self._init_plot(key, style_element, ranges=ranges, plots=plots)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 922, in _init_plot
    axis_specs['x']['x'] = (*self._axis_props(plots, subplots, element, ranges, pos=0), self.xaxis, {})
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/bokeh/element.py", line 746, in _axis_props
    l, b, r, t = self.get_extents(range_el, ranges)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 1502, in get_extents
    range_extents = self._get_range_extents(element, ranges, range_type, xdim, ydim, zdim)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 1413, in _get_range_extents
    xpad, ypad, zpad = self.get_padding(element, (x0, y0, z0, x1, y1, z1))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mliquet/dev/hvplot/.pixi/envs/default/lib/python3.12/site-packages/holoviews/plotting/plot.py", line 1380, in get_padding
    if aspect > 1:
       ^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'

maximlt avatar May 21 '25 11:05 maximlt