Datashader Charts#

line chart#

datashader.line(y, data_points=100, add_interaction=True, pixel_shade_type='linear', color=None, step_size=None, step_size_type=<class 'int'>, title='', timeout=100, unselected_alpha=0.2)#
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

title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

unselected_alpha: float [0, 1], default 0.2

if True, displays unselected data in the same color_palette but transparent(alpha=0.2)

Returns:
A cudashader scatter plot of type:

cuxfilter.charts.datashader.custom_extensions.InteractiveDatashaderLine

Example#

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

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 = line(x='x', y='y', unselected_alpha=0.2)

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

Scatter chart#

datashader.scatter(y, x_range=None, y_range=None, add_interaction=True, color_palette=None, aggregate_col=None, aggregate_fn='count', point_size=15, point_shape='circle', pixel_shade_type='eq_hist', pixel_density=0.5, pixel_spread='dynspread', tile_provider=None, title='', timeout=100, legend=True, legend_position='top_right', unselected_alpha=0.2, xaxis=False, yaxis=False)#
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/tuple of hex_color_codes,

or list/tuple of color names, default bokeh.palettes.Virisdis10

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.

tile_provider: str, default None

Underlying map type.See https://holoviews.org/reference/elements/bokeh/Tiles.html

title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

legend: bool, default True

Adds Bokeh.models.LinearColorMapper based legend if True, Note: legend currently only works with pixel_shade_type=’linear’/’log’

legend_position: str, default top_right

position of legend on the chart. Valid places are: right, left, bottom, top, top_right, top_left,

bottom_left, bottom_right

unselected_alpha: float [0, 1], default 0.2

if True, displays unselected data in the same color_palette but transparent(alpha=0.2)

xaxis: bool, default False

if True, displays the xaxis with labels

yaxis: bool, default False

if True, displays the yaxis with labels

Returns:
A cudashader scatter plot of type:

cuxfilter.charts.datashader.custom_extensions.InteractiveDatashaderPoints

Example#

from cuxfilter import DataFrame
from cuxfilter.charts import scatter
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)]}))
# setting pixel_shade_type='linear' to display legend (currently supports only log/linear)
scatter_chart = scatter(x='x',y='y', pixel_shade_type="linear", unselected_alpha=0.2)

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