Bird
0
0

Given the code below, what will be the output type?

medium📝 Predict Output Q4 of 15
Matplotlib - Performance and Large Data
Given the code below, what will be the output type?
import holoviews as hv
import datashader as ds
hv.extension('bokeh')
data = [(i, i**2) for i in range(1000000)]
points = hv.Points(data)
shaded = ds.Canvas().shade(points)
print(type(shaded))
A<class 'holoviews.core.element.Points'>
B<class 'datashader.transfer_functions.Image'>
C<class 'bokeh.plotting.figure.Figure'>
D<class 'matplotlib.figure.Figure'>
Step-by-Step Solution
Solution:
  1. Step 1: Understand what ds.Canvas().shade() returns

    Datashader's shade method returns an Image object representing the rasterized plot.
  2. Step 2: Identify the output type

    The printed type is datashader.transfer_functions.Image, not a HoloViews or Bokeh figure.
  3. Final Answer:

    <class 'datashader.transfer_functions.Image'> -> Option B
  4. Quick Check:

    Datashader shade output = Image object [OK]
Quick Trick: Datashader shade returns an Image object, not a plot figure [OK]
Common Mistakes:
  • Expecting a HoloViews Points object
  • Confusing with Bokeh or Matplotlib figure types
  • Assuming shade returns a plot directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes