MCPcopy Index your code
hub / github.com/bqplot/bqplot / _draw_mark

Function _draw_mark

bqplot/pyplot.py:539–612  ·  view source on GitHub ↗

Draw the mark of specified mark type. Parameters ---------- mark_type: type The type of mark to be drawn options: dict (default: {}) Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword

(mark_type, options={}, axes_options={}, **kwargs)

Source from the content-addressed store, hash-verified

537
538
539def _draw_mark(mark_type, options={}, axes_options={}, **kwargs):
540 """Draw the mark of specified mark type.
541
542 Parameters
543 ----------
544 mark_type: type
545 The type of mark to be drawn
546 options: dict (default: {})
547 Options for the scales to be created. If a scale labeled 'x' is
548 required for that mark, options['x'] contains optional keyword
549 arguments for the constructor of the corresponding scale type.
550 axes_options: dict (default: {})
551 Options for the axes to be created. If an axis labeled 'x' is required
552 for that mark, axes_options['x'] contains optional keyword arguments
553 for the constructor of the corresponding axis type.
554 figure: Figure or None
555 The figure to which the mark is to be added.
556 If the value is None, the current figure is used.
557 cmap: list or string
558 List of css colors, or name of bqplot color scheme
559 """
560 fig = kwargs.pop('figure', current_figure())
561 scales = kwargs.pop('scales', {})
562 update_context = kwargs.pop('update_context', True)
563
564 # Set the color map of the color scale
565 cmap = kwargs.pop('cmap', None)
566 if cmap is not None:
567 # Add the colors or scheme to the color scale options
568 options['color'] = dict(options.get('color', {}),
569 **_process_cmap(cmap))
570
571 # Going through the list of data attributes
572 for name in mark_type.class_trait_names(scaled=True):
573 dimension = _get_attribute_dimension(name, mark_type)
574 # TODO: the following should also happen if name in kwargs and
575 # scales[name] is incompatible.
576 if name not in kwargs:
577 # The scaled attribute is not being passed to the mark. So no need
578 # create a scale for this.
579 continue
580 elif name in scales:
581 if update_context:
582 _context['scales'][dimension] = scales[name]
583 # Scale has to be fetched from the context or created as it has not
584 # been passed.
585 elif dimension not in _context['scales']:
586 # Creating a scale for the dimension if a matching scale is not
587 # present in _context['scales']
588 traitlet = mark_type.class_traits()[name]
589 rtype = traitlet.get_metadata('rtype')
590 dtype = traitlet.validate(None, kwargs[name]).dtype
591 # Fetching the first matching scale for the rtype and dtype of the
592 # scaled attributes of the mark.
593 compat_scale_types = [
594 Scale.scale_types[key]
595 for key in Scale.scale_types
596 if Scale.scale_types[key].rtype == rtype and issubdtype(dtype, Scale.scale_types[key].dtype)

Callers 13

plotFunction · 0.85
imshowFunction · 0.85
ohlcFunction · 0.85
scatterFunction · 0.85
histFunction · 0.85
binFunction · 0.85
barFunction · 0.85
boxplotFunction · 0.85
pieFunction · 0.85
labelFunction · 0.85
geoFunction · 0.85
heatmapFunction · 0.85

Calls 5

current_figureFunction · 0.85
_process_cmapFunction · 0.85
_get_attribute_dimensionFunction · 0.85
axesFunction · 0.85
validateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…