Category Heatmap#

A heatmap showing the relationship between two categorical variables. This example uses the earthquakes dataset to count occurrences by magnitude and depth class.

import hvplot.pandas  # noqa
import numpy as np

df = hvplot.sampledata.earthquakes('pandas')

df.hvplot.heatmap(
    x='mag_class',
    y='depth_class',
    C='mag',
    reduce_function=np.size,
    fields={'mag': 'count'},  # for the tooltip to display count instead of mag 
    logz=True,
    title='Category Heatmap (Bokeh)',
    xlabel='Magnitude Class',
    ylabel='Depth Class',
)
import hvplot.pandas  # noqa
import numpy as np
hvplot.extension('matplotlib')

df = hvplot.sampledata.earthquakes('pandas')

df.hvplot.heatmap(
    x='mag_class',
    y='depth_class',
    C='mag',
    reduce_function=np.size,
    fields={'mag': 'count'},  # for the tooltip to display count instead of mag 
    logz=True,
    title='Category Heatmap (Matplotlib)',
    xlabel='Magnitude Class',
    ylabel='Depth Class',
)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.