Deckgl Charts#

Choropleth Chart#

deckgl.choropleth(color_column, elevation_column=None, color_aggregate_fn='count', color_factor=1, elevation_aggregate_fn='sum', elevation_factor=1, add_interaction=True, geoJSONSource=None, geoJSONProperty=None, geo_color_palette=None, mapbox_api_key=None, map_style=None, tooltip=True, tooltip_include_cols=[], nan_color='#d3d3d3', title='', x_range=None, y_range=None, opacity=None, layer_spec={})#
Parameters:
x: str

x-axis column name from the gpu dataframe

color_column: str

column name from the gpu dataframe on which color palettes are based on

elevation_column: str | Optional

column name from the gpu dataframe on which elevation scale is based on

color_aggregate_fn: {‘count’, ‘mean’, ‘sum’, ‘min’, ‘max’, ‘std’},
default “count”

aggregate function to be applied on the color column while performing groupby aggregation by column x

color_factor: float, default 1

factor to be multiplied to each value of color column before mapping the color

elevation_aggregate_fn: {‘count’, ‘mean’, ‘sum’, ‘min’, ‘max’, ‘std’},
default “count”

aggregate function to be applied on the elevation column while performing groupby aggregation by column x

elevation_factor: float, default 1

factor to be multiplied to each value of elevation column before scaling the elevation

add_interaction: {True, False}, default True
geoJSONSource: str

url to the geoJSON file

geoJSONProperty: str, optional

Property to use while doing aggregation operations using the geoJSON file. Defaults to the first value in properties in geoJSON file.

geo_color_palette: bokeh.palette, default bokeh.palettes.Inferno256
mapbox_api_key: str, default os.getenv(‘MAPBOX_API_KEY’)
map_style: str,
default based on cuxfilter.themes:

dark/rapids_dark theme: ‘mapbox://styles/mapbox/dark-v9’ default/rapids theme: ‘mapbox://styles/mapbox/light-v9’

URI for Mapbox basemap style. See Mapbox’s https://docs.mapbox.com/mapbox-gl-js/example/setstyle/ for examples

tooltip: {True, False}, default True
tooltip_include_cols: [], default list(dataframe.columns)
nan_color: hex color code, default cuxfilter.charts.CUXF_NAN_COLOR

color of the patches of value NaN in the map.

title: str,

chart title

x_range: tuple, default None (it’s calculated automatically)

tuple of min and max values for x-axis

y_range: tuple, default None (it’s calculated automatically)

tuple of min and max values for y-axis

opacity: float, default None

opacity of the chart

layer_spec: dict, default {}

deck.gl layer spec dictionary to override the default layer spec. For more information, see https://deck.gl/docs/api-reference/layers/polygon-layer

Returns:
A bokeh chart object of type choropleth (2d or 3d depending on the value

of elevation_column)

Example 3d-Choropleth#

import numpy as np
import cudf
import cuxfilter

geoJSONSource='https://raw.githubusercontent.com/rapidsai/cuxfilter/GTC-2018-mortgage-visualization/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json'
size = 1000

cux_df = cuxfilter.DataFrame.from_dataframe(
    cudf.DataFrame({
                    'color':np.random.randint(20,30, size=size*10)/100,
                    'zip': list(np.arange(1,1001))*10,
                    'elevation': np.random.randint(0,1000, size=size*10)
    })
)

chart0 = cuxfilter.charts.choropleth( x='zip', color_column='color', color_aggregate_fn='mean',
            elevation_column='elevation', elevation_factor=1000, elevation_aggregate_fn='mean',
        geoJSONSource=geoJSONSource, add_interaction=True
)

#declare dashboard
d = cux_df.dashboard([chart0],theme = cuxfilter.themes.dark, title='Mortgage Dashboard')

# use chart0.view() in a notebook cell to view the individual charts
chart0.view()

Example 2d-Choropleth#

import numpy as np
import cudf
import cuxfilter

geoJSONSource='https://raw.githubusercontent.com/rapidsai/cuxfilter/GTC-2018-mortgage-visualization/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json'
size = 1000

cux_df = cuxfilter.DataFrame.from_dataframe(
    cudf.DataFrame({
                    'color':np.random.randint(20,30, size=size*10)/100,
                    'zip': list(np.arange(1,1001))*10,
                    'elevation': np.random.randint(0,1000, size=size*10)
    })
)

chart0 = cuxfilter.charts.choropleth( x='zip', color_column='color', color_aggregate_fn='mean',
        geoJSONSource=geoJSONSource, add_interaction=True
)

#declare dashboard
d = cux_df.dashboard([chart0],theme = cuxfilter.themes.dark, title='Mortgage Dashboard')

# use chart0.view() in a notebook cell to view the individual charts
chart0.view()