# How to use "raster" aggregation with matplotlib-extension?

**URL:** <https://discourse.holoviz.org/t/how-to-use-raster-aggregation-with-matplotlib-extension/3754>\
**Category:** Datashader\
**Created:** [May 27, 2022, 1:24pm UTC](https://discourse.holoviz.org/t/how-to-use-raster-aggregation-with-matplotlib-extension/3754 "2022-05-27T13:24:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphaelquast](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/raphaelquast/32/3568_2.png) [@raphaelquast](https://discourse.holoviz.org/u/raphaelquast)\
**Post date:** [May 27, 2022, 1:24pm UTC](https://discourse.holoviz.org/t/how-to-use-raster-aggregation-with-matplotlib-extension/3754/1 "2022-05-27T13:24:18Z")

</div>

Hey,  
I’m working on some improvements for using datashader with [EOmaps](https://github.com/raphaelquast/EOmaps), and I’ve noticed that “mode” aggregation is only possible for “rasters”… however I could not find any indication on how to tell datashader that the data should be identified as a raster when using `mpl_ext.dsshow(...)`.

From what I’ve found so far, “raster”-aggregation should work something like this:

```auto
cvs = ds.Canvas(plot_width=1000, plot_height=1000)
agg = cvs.raster(<xarray.Dataset>, agg="mode")
agg.compute()

```

however within `mpl_ext.dsshow()` the canvas is used like this:

```auto
    def aggregate(self, x_range, y_range):
        """Aggregate data in given range to the window dimensions."""
        dims = self.axes.patch.get_window_extent().bounds

        if self.plot_width is None:
            plot_width = int(int(dims[2] + 0.5) * self.width_scale)
        else:
            plot_width = self.plot_width

        if self.plot_height is None:
            plot_height = int(int(dims[3] + 0.5) * self.height_scale)
        else:
            plot_height = self.plot_height

        canvas = Canvas(
            plot_width=plot_width,
            plot_height=plot_height,
            x_range=x_range,
            y_range=y_range,
        )
        binned = bypixel(self.df, canvas, self.glyph, self.aggregator)

        return binned

```

… and so I have no clue on how I could tell `bypixel` that I’d like raster-aggregation…

any help on this is highly appreciated… 🙂
