# Composing Plots¶

So far we have generated plots using hvPlot, but we haven't discussed what exactly these plots are and how they differ from the output of other libraries offering the .plot API. It turns out that as in the previous pn.interact example, the .hvplot() output is actually a rich, compositional object that can be used in many different ways, not just as an immediate plot. Specifically, hvPlot generates HoloViews objects rendered using the bokeh backend. In the previous notebook we saw that these objects are rendered as interactive Bokeh plots that support hovering, panning, and zooming.

In this notebook, we'll examine the output of hvPlot calls to take a look at individual HoloViews objects. Then we will see how these "elements" offer us powerful ways of combining and composing layered visualizations.

We'll read in the data as before, and also reindex by time so that we can do more easily do resampling.

In [1]:
import dask.dataframe as dd

In [2]:
df = dd.read_parquet('../data/earthquakes.parq')

In [3]:
cleaned_df = df.copy()
cleaned_df['mag'] = df.mag.where(df.mag > 0)
cleaned_reindexed_df = cleaned_df.set_index(cleaned_df.time).persist()


### Composing plots¶

In this section we'll start looking at how we can group plots to gain a deeper understanding of the data. We'll start by resampling the data to explore patterns in number and magnitude of earthquakes over time.

In [4]:
import hvplot.dask  # noqa: adds hvplot method to dask objects