Repository: holoviz/hvplot

Issue:
Expose more downsample algorithms and options
At the moment, I think, `downsample=True` is the only way to toggle the `downsample1d` and there's no way to customize how it's called, i.e. there's no way to set `algorithm` or some of its other options. Multiple options to implement that:

- Overload `downsample` to accept a string (`minmax`) or a dict (`{'algorithm': 'minmax', **other_downsample1d_opts}`)
- Just allow extra kwargs to be passed to hvPlot and catch them internally, like `max_px` and `threshold` for `dynspread`.
- Probably many other ways

Small preference for the first option.

cc @droumis 


Discussion:
IMO: overload downsample to accept a string. `True` could still default to use LTTB but we should allow for others, like `downsample='minmax'`, etc

Resolving patch:
diff --git a/hvplot/converter.py b/hvplot/converter.py
--- a/hvplot/converter.py
+++ b/hvplot/converter.py
@@ -206,9 +206,28 @@ class HoloViewsConverter:
         the Datashader library, returning an RGB object instead of
         individual points
     downsample (default=False):
-        Whether to apply LTTB (Largest Triangle Three Buckets)
-        downsampling to the element (note this is only well behaved for
-        timeseries data). Requires HoloViews >= 1.16.
+        Controls the application of downsampling to the plotted data,
+        which is particularly useful for large timeseries datasets to
+        reduce the amount of data sent to browser and improve
+        visualization performance. Requires HoloViews >= 1.16. Additional
+        dependencies: Installing the `tsdownsample` library is required
+        for using any downsampling methods other than the default 'lttb'.
+        Acceptable values:
+        - False: No downsampling is applied.
+        - True: Applies downsampling using HoloViews' default algorithm
+            (LTTB - Largest Triangle Three Buckets).
+        - 'lttb': Explicitly applies the Largest Triangle Three Buckets
+          algorithm.
+        - 'minmax': Applies the MinMax algorithm, selecting the minimum
+          and maximum values in each bin. Requires `tsdownsample`.
+        - 'm4': Applies the M4 algorithm, selecting the minimum, maximum,
+          first, and last values in each bin. Requires `tsdownsample`.
+        - 'minmax-lttb': Combines MinMax and LTTB algorithms for
+          downsampling, first applying MinMax to reduce to a preliminary
+          set of points, then LTTB for further reduction. Requires
+          `tsdownsample`.
+        Other string values corresponding to supported algorithms in
+        HoloViews may also be used.
     dynspread (default=False):
         For plots generated with datashade=True or rasterize=True,
         automatically increase the point size when the data is sparse
@@ -1321,6 +1340,11 @@ def method_wrapper(ds, x, y):
             except ImportError:
                 raise ImportError('Downsampling requires HoloViews >=1.16')
 
+            # Let HoloViews choose the default algo if 'downsample' is True.
+            # Otherwise, user-specified algorithm
+            if isinstance(self.downsample, str):
+                opts['algorithm'] = self.downsample
+
             if self.x_sampling:
                 opts['x_sampling'] = self.x_sampling
             if self._plot_opts.get('xlim') is not None:


Test patch:
diff --git a/hvplot/tests/testoperations.py b/hvplot/tests/testoperations.py
--- a/hvplot/tests/testoperations.py
+++ b/hvplot/tests/testoperations.py
@@ -319,3 +319,11 @@ def test_downsample_opts(self):
         assert plot.callback.operation.p.height == 50
         assert plot.callback.operation.p.x_sampling == 5
         assert plot.callback.operation.p.x_range == (0, 5)
+
+    def test_downsample_algorithm_minmax(self):
+        from holoviews.operation.downsample import downsample1d
+
+        plot = self.df.hvplot.line(downsample='minmax')
+
+        assert isinstance(plot.callback.operation, downsample1d)
+        assert plot.callback.operation_kwargs['algorithm'] == 'minmax'