# Small multiples aka facetted plots

**URL:** <https://discourse.holoviz.org/t/small-multiples-aka-facetted-plots/3760>\
**Category:** GeoViews\
**Created:** [May 29, 2022, 5:57pm UTC](https://discourse.holoviz.org/t/small-multiples-aka-facetted-plots/3760 "2022-05-29T17:57:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anitagraser](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/anitagraser/32/158_2.png) [@anitagraser](https://discourse.holoviz.org/u/anitagraser)\
**Post date:** [May 29, 2022, 5:57pm UTC](https://discourse.holoviz.org/t/small-multiples-aka-facetted-plots/3760/1 "2022-05-29T17:57:52Z")

</div>

I was hoping to be able to create small multiples using the keyword “by” (as described for scatter plots in [python - Create a grid of plots with holoviews/hvplot and set the max number of columns - Stack Overflow](https://stackoverflow.com/a/59642230))

```auto
nz.hvplot(by='Island', subplots=True)

```

Unfortunately, this fails with

```auto
File d:\mambaforge\envs\geocompy\lib\site-packages\holoviews\core\dimension.py:989, in Dimensioned.get_dimension(self, dimension, default, strict)
    987 name_map.update({util.dimension_sanitizer(dim.name): dim for dim in all_dims})
    988 if strict and dimension not in name_map:
--> 989 raise KeyError("Dimension %r not found." % dimension)
    990 else:
    991 return name_map.get(dimension, default)

KeyError: "Dimension 'Longitude' not found."

```

One workaround I’ve found is to create a Layout from a list of plots created like this instead:

```auto
Layout([group.hvplot(title=name) for name, group in nz.groupby('Island')])

```

But this feels much less intuitive.

Is there something I’m doing wrong when using “by”?

* * *

Full code:

> <https://github.com/geocompr/py/blob/df1ba6befc06490bb5067f31dcd7ef83276faeea/09-mapping.qmd#L87>

---

<div class="post-metadata">

**Author:** ![Hoxbro](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/hoxbro/32/3590_2.png) [@Hoxbro](https://discourse.holoviz.org/u/Hoxbro)\
**Post date:** [May 29, 2022, 8:27pm UTC](https://discourse.holoviz.org/t/small-multiples-aka-facetted-plots/3760/2 "2022-05-29T20:27:02Z")

</div>

I’m pretty sure it is a bug. An MRE is the following:

```python
import geopandas as gpd
import hvplot.pandas

countries = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
countries.hvplot(geo=True, by="continent", subplots=True)

```

I have got the MRE to work with `by` but not `subplots` (yet). Will make a PR when I figure it out.

edit: Got it to work with subplots too. Will make a PR in the coming week.

 ![image](https://discourse.holoviz.org/uploads/default/original/2X/4/4ef15b6e3611d175fd5f64939ffa7981d5694e67.png)

edit 2: The PRs are [holoviews #5325](https://github.com/holoviz/holoviews/pull/5325) and [hvplot #761](https://github.com/holoviz/hvplot/pull/761).

---

<div class="post-metadata">

**Author:** ![maximlt](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/maximlt/32/2487_2.png) [@maximlt](https://discourse.holoviz.org/u/maximlt)\
**Post date:** [May 31, 2022, 11:31am UTC](https://discourse.holoviz.org/t/small-multiples-aka-facetted-plots/3760/3 "2022-05-31T11:31:49Z")

</div>

That was fast!!! 🎉

---

<div class="post-metadata">

**Author:** ![anitagraser](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/anitagraser/32/158_2.png) [@anitagraser](https://discourse.holoviz.org/u/anitagraser)\
**Post date:** [May 31, 2022, 11:52am UTC](https://discourse.holoviz.org/t/small-multiples-aka-facetted-plots/3760/4 "2022-05-31T11:52:40Z")

</div>

Thanks so much for the quick action. This will be very useful.
