From 1ef1e26e7fcdb90958e9ba74c50390ac07484cd7 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 20 Sep 2023 15:08:36 +0200 Subject: [PATCH] Add autorange option (#1128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add autorange option * Add small documentation about autorange --------- Co-authored-by: Simon Høxbro Hansen --- examples/user_guide/Timeseries_Data.ipynb | 17 +++++++++++++++++ hvplot/converter.py | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/examples/user_guide/Timeseries_Data.ipynb b/examples/user_guide/Timeseries_Data.ipynb index e4ebe709f..18fc67563 100644 --- a/examples/user_guide/Timeseries_Data.ipynb +++ b/examples/user_guide/Timeseries_Data.ipynb @@ -56,6 +56,23 @@ "sst.hvplot(xformatter=formatter)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Auto range\n", + "Automatic auto-ranging on the data in x or y is supported, making it easy to scale the given axes and fit the entire visible curve after a zoom or pan." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sst.hvplot(autorange=\"y\")" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/hvplot/converter.py b/hvplot/converter.py index f17e81f56..b7d119038 100644 --- a/hvplot/converter.py +++ b/hvplot/converter.py @@ -84,6 +84,9 @@ class HoloViewsConverter: """ Generic options --------------- + autorange (default=None): Literal['x', 'y'] | None + Whether to enable auto-ranging along the x- or y-axis when + zooming. clim: tuple Lower and upper bound of the color scale cnorm (default='linear'): str @@ -383,7 +386,8 @@ def __init__( y_sampling=None, project=False, tools=[], attr_labels=None, coastline=False, tiles=False, sort_date=True, check_symmetric_max=1000000, transforms={}, stream=None, - cnorm=None, features=None, rescale_discrete_levels=None, **kwds + cnorm=None, features=None, rescale_discrete_levels=None, + autorange=None, **kwds ): # Process data and related options self._redim = fields @@ -485,6 +489,8 @@ def __init__( if ylim is not None: plot_opts['ylim'] = tuple(ylim) + plot_opts['autorange'] = autorange + self.invert = invert if loglog is not None: logx = logx or loglog