How to use the plotnine.scales.scale.scale_continuous function in plotnine

To help you get started, we’ve selected a few plotnine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github has2k1 / plotnine / plotnine / scales / scale_color.py View on Github external
@document
class scale_fill_grey(scale_color_grey):
    """
    Sequential grey color scale.

    Parameters
    ----------
    {superclass_parameters}
    """
    _aesthetics = ['fill']


# Continuous color scales #

@document
class scale_color_gradient(scale_continuous):
    """
    Create a 2 point color gradient

    Parameters
    ----------
    low : str
        low color
    high : str
        high color
    {superclass_parameters}
    na_value : str
        Color of missing values. Default is ``'None'``

    See Also
    --------
    :class:`.scale_color_gradient2`
github has2k1 / plotnine / plotnine / scales / scale.py View on Github external
kwargs['minor_breaks'] = date_breaks(minor_breaks)

        # Using the more specific parameters take precedence
        with suppress(KeyError):
            breaks_fmt = kwargs.pop('date_breaks')
            kwargs['breaks'] = date_breaks(breaks_fmt)

        with suppress(KeyError):
            labels_fmt = kwargs.pop('date_labels')
            kwargs['labels'] = date_format(labels_fmt)

        with suppress(KeyError):
            minor_breaks_fmt = kwargs.pop('date_minor_breaks')
            kwargs['minor_breaks'] = date_breaks(minor_breaks_fmt)

        scale_continuous.__init__(self, **kwargs)
github has2k1 / plotnine / plotnine / scales / scale_alpha.py View on Github external
from warnings import warn

import numpy as np
from mizani.palettes import rescale_pal

from ..doctools import document
from ..utils import alias
from ..exceptions import PlotnineWarning
from .scale import scale_discrete, scale_continuous, scale_datetime


@document
class scale_alpha(scale_continuous):
    """
    Continuous Alpha Scale

    Parameters
    ----------
    range : array_like
        Range ([Minimum, Maximum]) of output alpha values.
        Should be between 0 and 1. Default is ``(0.1, 1)``
    {superclass_parameters}
    """
    _aesthetics = ['alpha']

    def __init__(self, range=(0.1, 1), **kwargs):
        self.palette = rescale_pal(range)
        scale_continuous.__init__(self, **kwargs)
github has2k1 / plotnine / plotnine / guides / guide_colorbar.py View on Github external
def train(self, scale, aesthetic=None):
        if aesthetic is None:
            aesthetic = scale.aesthetics[0]

        # Do nothing if scales are inappropriate
        if set(scale.aesthetics) & self.available_aes == 0:
            warn("colorbar guide needs appropriate scales.", PlotnineWarning)
            return None

        if not issubclass(scale.__class__, scale_continuous):
            warn("colorbar guide needs continuous scales", PlotnineWarning)
            return None

        # value = breaks (numeric) is used for determining the
        # position of ticks
        limits = scale.limits
        breaks = scale.get_breaks(strict=True)
        breaks = np.asarray(breaks)
        breaks = breaks[~np.isnan(breaks)]

        if not len(breaks):
            return None

        self.key = pd.DataFrame({
            aesthetic: scale.map(breaks),
            'label': scale.get_labels(breaks),
github has2k1 / plotnine / plotnine / scales / scale_color.py View on Github external
def __init__(self, low='#132B43', high='#56B1F7', **kwargs):
        """
        Create colormap that will be used by the palette
        """
        self.palette = gradient_n_pal([low, high],
                                      name='gradient')
        scale_continuous.__init__(self, **kwargs)
github has2k1 / plotnine / plotnine / scales / scale_size.py View on Github external
Minimum and maximum area of the plotting symbol.
        It must be of size 2.
    {superclass_parameters}
    """
    _aesthetics = ['size']

    def __init__(self, range=(1, 6), **kwargs):
        self.palette = area_pal(range)
        scale_continuous.__init__(self, **kwargs)


alias('scale_size', scale_size_continuous)


@document
class scale_size_radius(scale_continuous):
    """
    Continuous radius size scale

    Parameters
    ----------
    range : array_like
        Minimum and maximum radius of the plotting symbol.
        It must be of size 2.
    {superclass_parameters}
    """
    _aesthetics = ['size']

    def __init__(self, range=(1, 6), **kwargs):
        self.palette = rescale_pal(range)
        scale_continuous.__init__(self, **kwargs)
github has2k1 / plotnine / plotnine / scales / scale_size.py View on Github external
def __init__(self, range=(1, 6), **kwargs):
        self.palette = area_pal(range)
        scale_continuous.__init__(self, **kwargs)
github has2k1 / plotnine / plotnine / scales / scale_linetype.py View on Github external
Parameters
    ----------
    {superclass_parameters}
    """
    _aesthetics = ['linetype']

    def __init__(self, **kwargs):
        warn(
            "Using linetype for an ordinal variable is not advised.",
            PlotnineWarning
        )
        super().__init__(**kwargs)


class scale_linetype_continuous(scale_continuous):
    def __init__(self):
        raise PlotnineError(
            "A continuous variable can not be mapped to linetype")


alias('scale_linetype_discrete', scale_linetype)
github has2k1 / plotnine / plotnine / scales / scale_size.py View on Github external
def __init__(self, range=(1, 6), **kwargs):
        self.palette = rescale_pal(range)
        scale_continuous.__init__(self, **kwargs)
github has2k1 / plotnine / plotnine / scales / scale_identity.py View on Github external
"""
    No linetype scaling

    Parameters
    ----------
    {superclass_parameters}
    guide : None | 'legend'
        Whether to include a legend. Default is None.
    """
    _aesthetics = ['linetype']
    palette = staticmethod(identity)
    guide = None


@document
class scale_alpha_identity(MapTrainMixin, scale_continuous):
    """
    No alpha scaling

    Parameters
    ----------
    {superclass_parameters}
    guide : None | 'legend'
        Whether to include a legend. Default is None.
    """
    _aesthetics = ['alpha']
    palette = staticmethod(identity)
    guide = None


@document
class scale_size_identity(MapTrainMixin, scale_continuous):