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)
| 537 | |
| 538 | |
| 539 | def _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) |
no test coverage detected
searching dependent graphs…