How to use the proplot.config.rc.fill function in proplot

To help you get started, we’ve selected a few proplot 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 lukelbd / proplot / proplot / axes / geo.py View on Github external
def _get_boundary_props(self):
        """
        Return map boundary properties.
        """
        rc_mode = rc._get_context_mode()
        kw_face = rc.fill(
            {
                'facecolor': 'axes.facecolor',
                'alpha': 'axes.alpha',
            },
            context=(rc_mode == 2),
        )
        kw_edge = rc.fill(
            {
                'linewidth': 'axes.linewidth',
                'edgecolor': 'axes.edgecolor',
            },
            context=(rc_mode == 2),
        )
        kw_edge['capstyle'] = 'projecting'  # NOTE: needed to fix cartopy bounds
        return kw_face, kw_edge
github lukelbd / proplot / proplot / axes / base.py View on Github external
obj_ref = self._get_title(loc)
                obj.set_ha(obj_ref.get_ha())
                obj.set_va(obj_ref.get_va())
                obj.set_transform(obj_ref.get_transform())
                obj.set_position(obj_ref.get_position())
            obj.update(kw)
            self._abc_loc = loc

        # Titles, with two workflows here:
        # 1. title='name' and titleloc='position'
        # 2. ltitle='name', rtitle='name', etc., arbitrarily many titles
        # NOTE: Matplotlib added axes.titlecolor in version 3.2 but we
        # still use custom title.size, title.weight, title.color
        # properties for retroactive support in older matplotlib versions.
        # First get params and update kwargs
        kw = rc.fill(
            {
                'fontsize': 'title.size',
                'weight': 'title.weight',
                'color': 'title.color',
                'fontfamily': 'font.family',
            },
            context=True
        )
        if 'color' in kw and kw['color'] == 'auto':
            del kw['color']  # WARNING: matplotlib permits invalid color here
        kwb = rc.fill(
            {
                'border': 'title.border',
                'borderwidth': 'title.borderwidth',
            },
            context=True,
github lukelbd / proplot / proplot / axes / cartesian.py View on Github external
proplot.config.RcConfigurator.context
        proplot.axes.Axes.format

        Note
        ----
        If you plot something with a `datetime64 \
`__,
        `pandas.Timestamp`, `pandas.DatetimeIndex`, `datetime.date`,
        `datetime.time`, or `datetime.datetime` array as the *x* or *y* axis
        coordinate, the axis ticks and tick labels will be automatically
        formatted as dates.
        """
        rc_kw, rc_mode, kwargs = self._parse_format(**kwargs)
        with rc.context(rc_kw, mode=rc_mode):
            # Background patch
            kw_face = rc.fill(
                {
                    'facecolor': 'axes.facecolor',
                    'alpha': 'axes.alpha'
                },
                context=True,
            )
            patch_kw = patch_kw or {}
            kw_face.update(patch_kw)
            self.patch.update(kw_face)

            # No mutable default args
            xlabel_kw = xlabel_kw or {}
            ylabel_kw = ylabel_kw or {}
            xscale_kw = xscale_kw or {}
            yscale_kw = yscale_kw or {}
            xlocator_kw = xlocator_kw or {}
github lukelbd / proplot / proplot / axes / plot.py View on Github external
kw_text[key] = value
    kw_handle = {'solid_capstyle': 'butt'}
    for key, value in (
        ('color', color),
        ('marker', marker),
        ('linewidth', lw),
        ('linewidth', linewidth),
        ('markersize', markersize),
        ('linestyle', linestyle),
        ('dashes', dashes),
    ):
        if value is not None:
            kw_handle[key] = value

    # Legend box properties
    outline = rc.fill(
        {
            'linewidth': 'axes.linewidth',
            'edgecolor': 'axes.edgecolor',
            'facecolor': 'axes.facecolor',
            'alpha': 'legend.framealpha',
        }
    )
    for key in (*outline,):
        if key != 'linewidth':
            if kwargs.get(key, None):
                outline.pop(key, None)

    # Get axes for legend handle detection
    # TODO: Update this when no longer use "filled panels" for outer legends
    axs = [self]
    if self._panel_hidden:
github lukelbd / proplot / proplot / axes / base.py View on Github external
See also
        --------
        proplot.config.RcConfigurator.context
        proplot.axes.CartesianAxes.format
        proplot.axes.PolarAxes.format
        proplot.axes.GeoAxes.format
        """
        # Misc axes settings
        # TODO: Add more settings to this?
        cycle = rc.get('axes.prop_cycle', context=True)
        if cycle is not None:
            self.set_prop_cycle(cycle)

        # Figure patch (for some reason needs to be re-asserted even if
        # declared before figure is drawn)
        kw = rc.fill({'facecolor': 'figure.facecolor'}, context=True)
        self.figure.patch.update(kw)
        if abovetop is not None:
            self._above_top_panels = abovetop
        pad = rc.get('axes.titlepad', context=True)
        if pad is not None:
            self._set_title_offset_trans(pad)
            self._title_pad = pad

        # Super title
        # NOTE: These are actually *figure-wide* settings, but that line
        # gets blurred where we have shared axes, spanning labels, and
        # whatnot. May result in redundant assignments if formatting more than
        # one axes, but operations are fast so some redundancy is nbd.
        # NOTE: Below kludge prevents changed *figure-wide* settings
        # from getting overwritten when user makes a new axes.
        fig = self.figure
github lukelbd / proplot / proplot / axes / polar.py View on Github external
# Spine settings
                kw = rc.fill(
                    {
                        'linewidth': 'axes.linewidth',
                        'color': 'axes.edgecolor',
                    },
                    context=True,
                )
                sides = ('inner', 'polar') if r == 'r' else ('start', 'end')
                spines = [self.spines[side] for side in sides]
                for spine, side in zip(spines, sides):
                    spine.update(kw)

                # Grid and grid label settings
                # NOTE: Not sure if polar lines inherit tick or grid props
                kw = rc.fill(
                    {
                        'color': x + 'tick.color',
                        'labelcolor': 'tick.labelcolor',  # new props
                        'labelsize': 'tick.labelsize',
                        'grid_color': 'grid.color',
                        'grid_alpha': 'grid.alpha',
                        'grid_linewidth': 'grid.linewidth',
                        'grid_linestyle': 'grid.linestyle',
                    },
                    context=True,
                )
                axis.set_tick_params(which='both', **kw)
                # Label settings that can't be controlled with set_tick_params
                kw = rc.fill(
                    {
                        'fontfamily': 'font.family',
github lukelbd / proplot / proplot / axes / geo.py View on Github external
def _get_gridline_props(self, which='major', context=True):
        """
        Get dictionaries of gridline properties for lines and text.
        """
        # Line properties
        # WARNING: Here we use apply existing *matplotlib* rc param to brand new
        # *proplot* setting. So if rc mode is 1 (first format call) use context=False.
        key = 'grid' if which == 'major' else 'gridminor'
        kwlines = rc.fill(
            {
                'alpha': f'{key}.alpha',
                'color': f'{key}.color',
                'linewidth': f'{key}.linewidth',
                'linestyle': f'{key}.linestyle',
            },
            context=context,
        )
        axisbelow = rc.get('axes.axisbelow', context=True)
        if axisbelow is not None:
            kwlines['zorder'] = self._axis_below_to_zorder(axisbelow)

        # Text properties
        kwtext = {}
        if which == 'major':
            kwtext = rc.fill(
github lukelbd / proplot / proplot / axes / geo.py View on Github external
{
                'alpha': f'{key}.alpha',
                'color': f'{key}.color',
                'linewidth': f'{key}.linewidth',
                'linestyle': f'{key}.linestyle',
            },
            context=context,
        )
        axisbelow = rc.get('axes.axisbelow', context=True)
        if axisbelow is not None:
            kwlines['zorder'] = self._axis_below_to_zorder(axisbelow)

        # Text properties
        kwtext = {}
        if which == 'major':
            kwtext = rc.fill(
                {
                    'color': f'{key}.labelcolor',
                    'fontsize': f'{key}.labelsize',
                    'weight': f'{key}.labelweight',
                },
                context=context,
            )

        return kwlines, kwtext
github lukelbd / proplot / proplot / axes / base.py View on Github external
fig._update_super_title(suptitle, **kw)

        # Labels
        rlabels = _not_none(rightlabels=rightlabels, rlabels=rlabels)
        blabels = _not_none(bottomlabels=bottomlabels, blabels=blabels)
        llabels = _not_none(
            rowlabels=rowlabels, leftlabels=leftlabels, llabels=llabels,
        )
        tlabels = _not_none(
            collabels=collabels, toplabels=toplabels, tlabels=tlabels,
        )
        for side, labels in zip(
            ('left', 'right', 'top', 'bottom'),
            (llabels, rlabels, tlabels, blabels)
        ):
            kw = rc.fill(
                {
                    'fontsize': side + 'label.size',
                    'weight': side + 'label.weight',
                    'color': side + 'label.color',
                    'fontfamily': 'font.family'
                },
                context=True,
            )
            if labels or kw:
                fig._update_subplot_labels(self, side, labels, **kw)

        # Helper function
        def sanitize_kw(kw, loc):
            kw = kw.copy()
            if loc in ('left', 'right', 'center'):
                kw.pop('border', None)
github lukelbd / proplot / proplot / axes / base.py View on Github external
self._set_title_offset_trans(pad)
            self._title_pad = pad

        # Super title
        # NOTE: These are actually *figure-wide* settings, but that line
        # gets blurred where we have shared axes, spanning labels, and
        # whatnot. May result in redundant assignments if formatting more than
        # one axes, but operations are fast so some redundancy is nbd.
        # NOTE: Below kludge prevents changed *figure-wide* settings
        # from getting overwritten when user makes a new axes.
        fig = self.figure
        suptitle = _not_none(figtitle=figtitle, suptitle=suptitle)
        if len(fig._axes_main) > 1 and rc._context and rc._context[-1].mode == 1:
            kw = {}
        else:
            kw = rc.fill(
                {
                    'fontsize': 'suptitle.size',
                    'weight': 'suptitle.weight',
                    'color': 'suptitle.color',
                    'fontfamily': 'font.family'
                },
                context=True,
            )
        if suptitle or kw:
            fig._update_super_title(suptitle, **kw)

        # Labels
        rlabels = _not_none(rightlabels=rightlabels, rlabels=rlabels)
        blabels = _not_none(bottomlabels=bottomlabels, blabels=blabels)
        llabels = _not_none(
            rowlabels=rowlabels, leftlabels=leftlabels, llabels=llabels,