How to use the plotnine.geoms.geom.geom 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 / geoms / geom_dotplot.py View on Github external
from warnings import warn

import numpy as np
import matplotlib.collections as mcoll
import matplotlib.patches as mpatches
import matplotlib.lines as mlines

from ..exceptions import PlotnineWarning
from ..utils import groupby_apply, to_rgba, resolution
from ..doctools import document
from .geom import geom


@document
class geom_dotplot(geom):
    """
    Dot plot

    {usage}

    Parameters
    ----------
    {common_parameters}
    stackdir : str (default: up)
        Direction in which to stack the dots. Options are
        :py:`['up', 'down', 'center', 'centerwhole']`
    stackratio : float (default: 1)
        How close to stack the dots. If value is less than 1,
        the dots overlap, if greater than 1 they are spaced.
    dotsize : float (default: 1)
        Diameter of dots relative to ``binwidth``.
github has2k1 / plotnine / plotnine / geoms / geom_vline.py View on Github external
def __init__(self, mapping=None, data=None, **kwargs):
        mapping, data = order_as_mapping_data(mapping, data)
        xintercept = kwargs.pop('xintercept', None)
        if xintercept is not None:
            if mapping:
                warn("The 'xintercept' parameter has overridden "
                     "the aes() mapping.", PlotnineWarning)
            data = pd.DataFrame({'xintercept': make_iterable(xintercept)})
            mapping = aes(xintercept='xintercept')
            kwargs['show_legend'] = False

        geom.__init__(self, mapping, data, **kwargs)
github has2k1 / plotnine / plotnine / geoms / geom_segment.py View on Github external
import numpy as np
import pandas as pd
import matplotlib.collections as mcoll

from ..utils import to_rgba, make_line_segments, interleave
from ..utils import SIZE_FACTOR
from ..doctools import document
from .geom import geom


@document
class geom_segment(geom):
    """
    Line segments

    {usage}

    Parameters
    ----------
    {common_parameters}
    lineend : str (default: butt)
        Line end style, of of *butt*, *round* or *projecting.*
        This option is applied for solid linetypes.
    arrow : plotnine.geoms.geom_path.arrow (default: None)
        Arrow specification. Default is no arrow.

    See Also
    --------
github has2k1 / plotnine / plotnine / geoms / geom_step.py View on Github external
Parameters
    ----------
    {common_parameters}
    direction : str, optional (default: hv)
        One of *hv*, *vh* or *mid*, for horizontal-vertical steps,
        vertical-horizontal steps or steps half-way between adjacent
        x values.

    See Also
    --------
    plotnine.geoms.geom_path : For documentation of extra
        parameters.
    """
    DEFAULT_PARAMS = {'stat': 'identity', 'position': 'identity',
                      'na_rm': False, 'direction': 'hv'}
    draw_panel = geom.draw_panel

    @staticmethod
    def draw_group(data, panel_params, coord, ax, **params):
        direction = params['direction']
        n = len(data)
        data = data.sort_values('x', kind='mergesort')
        x = data['x'].values
        y = data['y'].values

        if direction == 'vh':
            # create stepped path -- interleave x with
            # itself and y with itself
            xidx = np.repeat(range(n), 2)[:-1]
            yidx = np.repeat(range(n), 2)[1:]
            new_x, new_y = x[xidx], y[yidx]
        elif direction == 'hv':
github has2k1 / plotnine / plotnine / geoms / geom_rect.py View on Github external
from matplotlib.collections import PolyCollection
import numpy as np
import pandas as pd

from ..utils import to_rgba, SIZE_FACTOR
from ..doctools import document
from .geom import geom
from .geom_polygon import geom_polygon


@document
class geom_rect(geom):
    """
    Rectangles

    {usage}

    Parameters
    ----------
    {common_parameters}
    """

    DEFAULT_AES = {'color': None, 'fill': '#595959',
                   'linetype': 'solid', 'size': 0.5, 'alpha': 1}
    REQUIRED_AES = {'xmax', 'xmin', 'ymax', 'ymin'}
    DEFAULT_PARAMS = {'stat': 'identity', 'position': 'identity',
                      'na_rm': False}
    legend_geom = 'polygon'
github has2k1 / plotnine / plotnine / geoms / geom_path.py View on Github external
import numpy as np
import matplotlib.collections as mcoll
import matplotlib.lines as mlines
import matplotlib.patches as mpatches
import matplotlib.path as mpath

from ..exceptions import PlotnineWarning
from ..doctools import document
from ..utils import to_rgba, make_line_segments
from ..utils import SIZE_FACTOR, match
from .geom import geom


@document
class geom_path(geom):
    """
    Connected points

    {usage}

    Parameters
    ----------
    {common_parameters}
    lineend : str (default: butt)
        Line end style, of of *butt*, *round* or *projecting.*
        This option is applied for solid linetypes.
    linejoin : str (default: round)
        Line join style, one of *round*, *miter* or *bevel*.
        This option is applied for solid linetypes.
    arrow : plotnine.geoms.geom_path.arrow (default: None)
        Arrow specification. Default is no arrow.
github has2k1 / plotnine / plotnine / geoms / annotation_stripes.py View on Github external
Other aesthetic parameters for the rectangular stripes.
        They include; *alpha*, *color*, *linetype*, and *size*.
    """

    def __init__(self, fill=('#AAAAAA', '#CCCCCC'), fill_range=False,
                 direction='vertical', extend=(0, 1), **kwargs):
        allowed = ('vertical', 'horizontal')
        if direction not in allowed:
            raise ValueError(
                "direction must be one of {}".format(allowed))
        self._annotation_geom = _geom_stripes(
            fill=fill, fill_range=fill_range, extend=extend,
            direction=direction, **kwargs)


class _geom_stripes(geom):

    DEFAULT_AES = {}
    REQUIRED_AES = set()
    DEFAULT_PARAMS = {'stat': 'identity', 'position': 'identity',
                      'na_rm': False, 'color': None,
                      'fill': ('#AAAAAA', '#CCCCCC'),
                      'linetype': 'solid', 'size': 1, 'alpha': 0.5,
                      'direction': 'vertical', 'extend': (0, 1),
                      'fill_range': False}
    legend_geom = "polygon"

    @staticmethod
    def draw_group(data, panel_params, coord, ax, **params):
        extend = params['extend']
        fill_range = params['fill_range']
        direction = params['direction']
github has2k1 / plotnine / plotnine / geoms / geom_vline.py View on Github external
from warnings import warn

import pandas as pd
import matplotlib.lines as mlines

from ..utils import make_iterable, SIZE_FACTOR, order_as_mapping_data
from ..exceptions import PlotnineWarning
from ..doctools import document
from ..aes import aes
from .geom import geom
from .geom_segment import geom_segment


@document
class geom_vline(geom):
    """
    Vertical line

    {usage}

    Parameters
    ----------
    {common_parameters}
    """
    DEFAULT_AES = {'color': 'black', 'linetype': 'solid',
                   'size': 0.5, 'alpha': 1}
    REQUIRED_AES = {'xintercept'}
    DEFAULT_PARAMS = {'stat': 'identity', 'position': 'identity',
                      'na_rm': False, 'inherit_aes': False}

    def __init__(self, mapping=None, data=None, **kwargs):
github has2k1 / plotnine / plotnine / geoms / geom_ribbon.py View on Github external
from ..coords import coord_flip
from ..utils import to_rgba, groupby_with_null, SIZE_FACTOR
from ..doctools import document
from ..exceptions import PlotnineError
from .geom import geom


@document
class geom_ribbon(geom):
    """
    Ribbon plot

    {usage}

    Parameters
    ----------
    {common_parameters}
    """
    DEFAULT_AES = {'alpha': 1, 'color': None, 'fill': '#333333',
                   'linetype': 'solid', 'size': 0.5}
    REQUIRED_AES = {'x', 'ymax', 'ymin'}
    DEFAULT_PARAMS = {'stat': 'identity', 'position': 'identity',
                      'na_rm': False}
    legend_geom = 'polygon'
github has2k1 / plotnine / plotnine / geoms / geom_polygon.py View on Github external
import numpy as np
from matplotlib.collections import PolyCollection
from matplotlib.patches import Rectangle

from ..utils import to_rgba, SIZE_FACTOR
from ..doctools import document
from .geom import geom


@document
class geom_polygon(geom):
    """
    Polygon, a filled path

    {usage}

    Parameters
    ----------
    {common_parameters}

    Notes
    -----
    All paths in the same ``group`` aesthetic value make up a polygon.
    """
    DEFAULT_AES = {'alpha': 1, 'color': None, 'fill': '#333333',
                   'linetype': 'solid', 'size': 0.5}
    DEFAULT_PARAMS = {'stat': 'identity', 'position': 'identity',