Exemple #1
0
def vectorbar(object=None, title=None, orientation=None, nb_labels=None, nb_colors=None, label_fmt=None):
    """Adds a colorbar for the vector color mapping of the given object.

    If no object is specified, the first object with vector data in the scene
    is used.

    **Keyword arguments**

        :object: Optional object to get the vector color map from

        :title: The title string

        :orientation: Can be 'horizontal' or 'vertical'

        :nb_labels: The number of labels to display on the colorbar.

        :label_fmt: The string formater for the labels. This needs to be
                    a formater for float number, eg '%.1f'.

        :nb_colors: The maximum number of colors displayed on the
                    colorbar.
    """
    module_manager = tools._find_module_manager(object=object, data_type="vector")
    if module_manager is None:
        return
    if not module_manager.vector_lut_manager.show_scalar_bar:
        if title is None:
            title = ""
        orientation = "horizontal"
    lut_mgr = module_manager.vector_lut_manager
    lut_mgr.show_scalar_bar = True
    _lut_manager_properties(
        lut_mgr, title=title, orientation=orientation, nb_labels=nb_labels, nb_colors=nb_colors, label_fmt=label_fmt
    )
    return lut_mgr
Exemple #2
0
def scalarbar(object=None,
              title=None,
              orientation=None,
              nb_labels=None,
              nb_colors=None,
              label_fmt=None):
    """Adds a colorbar for the scalar color mapping of the given object.

    If no object is specified, the first object with scalar data in the scene
    is used.

    **Keyword arguments**:

        :object: Optional object to get the scalar color map from

        :title: The title string

        :orientation: Can be 'horizontal' or 'vertical'

        :nb_labels: The number of labels to display on the colorbar.

        :label_fmt: The string formater for the labels. This needs to be
                    a formater for float number, eg '%.1f'.

        :nb_colors: The maximum number of colors displayed on the
                    colorbar.
    """
    module_manager = tools._find_module_manager(object=object,
                                                data_type="scalar")
    if module_manager is None:
        return
    if not module_manager.scalar_lut_manager.show_scalar_bar:
        if title is None:
            title = ''
        if orientation is None:
            orientation = 'horizontal'
    lut_mgr = module_manager.scalar_lut_manager
    module_manager.scalar_lut_manager.show_scalar_bar = True
    _lut_manager_properties(lut_mgr,
                            title=title,
                            orientation=orientation,
                            nb_labels=nb_labels,
                            nb_colors=nb_colors,
                            label_fmt=label_fmt)
    return lut_mgr