datashader Charts

line chart

datashader.line(x, y, data_points=100, add_interaction=True, pixel_shade_type='linear', color=None, step_size=None, step_size_type=<class 'int'>, width=800, height=400, **library_specific_params)
Parameters
x: str

x-axis column name from the gpu dataframe

y: str

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[y].min(), gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
pixel_shade_type: str, default ‘linear’

The “how” parameter in datashader.transfer_functions.shade() function. Available options: eq_hist, linear, log, cbrt

color: str, default #8735fb
step_size: int, default None

for the range_slider below the chart

step_size_type: type, default int

for the range_slider below the chart

width: int, default 800
height: int, default 400
title: str,

chart title

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader scatter plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import DataFrame
from cuxfilter.charts import datashader
import numpy as np
import cudf
import random

n = 100000                           # Number of points
start = 1456297053                   # Start time
end = start + 60 * 60 * 24

cux_df = DataFrame.from_dataframe(cudf.DataFrame({'x': np.linspace(start, end, n), 'y':np.random.normal(0, 0.3, size=n).cumsum() + 50}))
line_chart_1 = datashader.line(x='x', y='y')

d = cux_df.dashboard([line_chart_1])
line_chart_1.view()

Scatter_geo chart

datashader.scatter_geo(x, y=None, x_range=None, y_range=None, add_interaction=True, color_palette=None, aggregate_col=None, aggregate_fn='count', point_size=1, point_shape='circle', pixel_shade_type='eq_hist', pixel_density=0.5, pixel_spread='dynspread', width=800, height=400, tile_provider='CARTODBPOSITRON', **library_specific_params)
Parameters
x: str

x-axis column name from the gpu dataframe

y: str, default None

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
color_palette: bokeh.palettes or list of hex_color_codes, or list of color

names, default inferno

aggregate_col: str, default None

Column from the gpu dataframe on which the aggregate_fn will be run on, if None, aggregate_fn is run on y-column.

aggregate_fn: {‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
point_size: int, default 1

Point size in the scatter plot.

point_shape: str, default ‘circle’

Available options: circle, square, rect_vertical, rect_horizontal.

pixel_shade_type: str, default ‘eq_hist’

The “how” parameter in datashader.transfer_functions.shade() function. Available options: eq_hist, linear, log, cbrt

pixel_density: float, default 0.5

A tuning parameter in [0, 1], with higher values giving more dense scatter plot.

pixel_spread: str, default ‘dynspread’

dynspread: Spread pixels in an image dynamically based on the image density. spread: Spread pixels in an image.

width: int, default 800
height: int, default 400
tile_provider: str, default ‘CARTODBPOSITRON’

Underlying map type.See https://bokeh.pydata.org/en/latest/docs/reference/tile_providers.html

title: str,

chart title

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader geo-scatter plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import DataFrame
from cuxfilter.charts import datashader
import cudf
import random

cux_df = DataFrame.from_dataframe(cudf.DataFrame({'x': [float(random.randrange(-8239000,-8229000)) for i in range(100000)], 'y':[float(random.randrange(4960000, 4980000)) for i in range(100000)]}))

scatter_geo_chart = datashader.scatter_geo(x='x',
                                    y='y')

d = cux_df.dashboard([scatter_geo_chart])
scatter_geo_chart.view()

Scatter chart

datashader.scatter(x, y, x_range=None, y_range=None, add_interaction=True, color_palette=None, aggregate_col=None, aggregate_fn='count', point_size=1, point_shape='circle', pixel_shade_type='eq_hist', pixel_density=0.5, pixel_spread='dynspread', width=800, height=400, **library_specific_params)
Parameters
x: str

x-axis column name from the gpu dataframe

y: str, default None

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[y].min(), gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
color_palette: bokeh.palettes or list of hex_color_codes, or list of

color names, default inferno

aggregate_col: str, default None

column from the gpu dataframe on which the aggregate_fn will be run on, if None, aggregate_fn is run on y-column

aggregate_fn: {‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
point_size: int, default 1

Point size in the scatter plot.

point_shape: str, default ‘circle’

Available options: circle, square, rect_vertical, rect_horizontal.

pixel_shade_type: str, default ‘eq_hist’

The “how” parameter in datashader.transfer_functions.shade() function. Available options: eq_hist, linear, log, cbrt

pixel_density: float, default 0.5

A tuning parameter in [0, 1], with higher values giving more dense scatter plot.

pixel_spread: str, default ‘dynspread’

dynspread: Spread pixels in an image dynamically based on the image density. spread: Spread pixels in an image.

width: int, default 800
height: int, default 400
title: str,

chart title

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader scatter plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import DataFrame
from cuxfilter.charts import datashader
import cudf
import random

cux_df = DataFrame.from_dataframe(cudf.DataFrame({'x': [float(random.randrange(-8239000,-8229000)) for i in range(10000)], 'y':[float(random.randrange(4960000, 4980000)) for i in range(10000)]}))

scatter_chart = datashader.scatter(x='x',
                                     y='y')

d = cux_df.dashboard([scatter_chart])
scatter_chart.view()

Stacked_Lines chart

datashader.stacked_lines(x, y, data_points=100, add_interaction=True, colors=[], step_size=None, step_size_type=<class 'int'>, width=800, height=400, **library_specific_params)

stacked lines chart

Parameters
x: str

x-axis column name from the gpu dataframe

y: list

y-axis column names from the gpu dataframe for the stacked lines

add_interaction: {True, False}, default True
colors: list, default [#8735fb, #8735fb, ….]
step_size: int, default None

for the range_slider below the chart

step_size_type: type, default int

for the range_slider below the chart

width: int, default 800
height: int, default 400
title: str,

chart title

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader stacked_lines plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter.sampledata import signals_data
from cuxfilter import DataFrame
from cuxfilter.charts import datashader

cux_df = DataFrame.from_dataframe(signals_data)

stacked_lines_chart = datashader.stacked_lines(x='Time', y=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'],
                                                    colors = ["red", "grey", "black", "purple", "pink",
                                                            "yellow", "brown", "green", "orange", "blue"]
                                                    )

d = cux_df.dashboard([stacked_lines_chart])

stacked_lines_chart.view()

Heat Map chart

datashader.heatmap(x, y, x_range=None, y_range=None, add_interaction=True, color_palette=None, aggregate_col=None, aggregate_fn='mean', point_size=10, point_shape='rect_vertical', width=800, height=400, **library_specific_params)

Heatmap using default datashader.scatter plot with slight modifications. Added for better defaults. In theory, scatter directly can be used to generate the same.

Parameters
x: str

x-axis column name from the gpu dataframe

y: str, default None

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[y].min(), gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
color_palette: bokeh.palettes or list of hex_color_codes, or

list of color names, default inferno

aggregate_col: str, default None

column from the gpu dataframe on which the aggregate_fn will be run on, if None, aggregate_fn is run on y-column

aggregate_fn: {‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
point_size: int, default 1

Point size in the scatter plot.

point_shape: str, default ‘rect_vertical’

Available options: circle, square, rect_vertical, rect_horizontal.

pixel_density: float, default 0.5

A tuning parameter in [0, 1], with higher values giving more dense scatter plot.

pixel_spread: str, default ‘dynspread’

dynspread: Spread pixels in an image dynamically based on the image density. spread: Spread pixels in an image.

width: int, default 800
height: int, default 400
title: str,

chart title

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader heatmap (scatter object).
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import layouts, themes, DataFrame
from cuxfilter.charts import datashader
from cuxfilter.sampledata import unemployment_data

cux_df = DataFrame.from_dataframe(unemployment_data)

# this is the colormap from the original NYTimes plot
colors = ["#75968f", "#a5bab7", "#c9d9d3", "#e2e2e2", "#dfccce", "#ddb7b1", "#cc7878", "#933b41", "#550b1d"]

chart1 = datashader.heatmap(x='Year', y='Month', aggregate_col='rate',
                            color_palette=colors, point_size=20)

d = cux_df.dashboard([chart1], layout=layouts.single_feature, theme=themes.dark)

chart1.view()