0
0
Matplotlibdata~10 mins

Alternatives for big data (Datashader, HoloViews) in Matplotlib - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Datashader library.

Matplotlib
import [1]
Drag options to blanks, or click blank then click option'
Amatplotlib
Bdatashader
Cpandas
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing matplotlib instead of datashader.
Using pandas or numpy which are not for big data visualization.
2fill in blank
medium

Complete the code to create a canvas with Datashader for a 1000x1000 pixel plot.

Matplotlib
canvas = datashader.Canvas([1]=1000, [2]=1000)
Drag options to blanks, or click blank then click option'
Asize
Bheight
Cwidth
Dshape
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'size' or 'shape' which are not parameters for Canvas.
Confusing width and height.
3fill in blank
hard

Fix the error in the code to aggregate points using Datashader's points method.

Matplotlib
agg = canvas.points(df, x='x', y='y', [1]='value')
Drag options to blanks, or click blank then click option'
Aagg_column
Bagg
Cagg_func
Dagg_col
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'agg' or 'agg_func' which are not valid parameters.
Misspelling the parameter name.
4fill in blank
hard

Fill both blanks to create a HoloViews Points plot and display it.

Matplotlib
import holoviews as hv
hv.extension('matplotlib')
points = hv.Points(df, kdims=[[1]], vdims=[[2]])
points.opts(color='blue', size=5)
Drag options to blanks, or click blank then click option'
A'x'
B'y'
C'value'
D'index'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping key and value dimensions.
Using 'index' which is not a data column.
5fill in blank
hard

Fill all three blanks to create a Datashader aggregate and convert it to an image with HoloViews.

Matplotlib
agg = canvas.points(df, x=[1], y=[2], agg_col=[3])
img = hv.Image(agg)
img.opts(cmap='viridis')
Drag options to blanks, or click blank then click option'
A'x'
B'y'
C'value'
D'count'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' as agg_col which is not a data column.
Mixing up x and y parameters.