How to use the proplot.rctools.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.py View on Github external
def _title_kwargs(self, abc=False, loc=None):
        """Position title text to the left, center, or right and either
        inside or outside the axes. The default is center, outside."""
        # Apply rc settings
        prefix = 'abc' if abc else 'title'
        kwargs = rc.fill({
            'fontsize':   f'{prefix}.fontsize',
            'weight':     f'{prefix}.weight',
            'color':      f'{prefix}.color',
            'fontfamily': 'font.family'
            })
        if loc is None:
            loc = rc[f'{prefix}.loc']
        if loc is None:
            return kwargs

        # Add border props if we are moving it
        kwargs.update(rc.fill({
            'border':    f'{prefix}.border',
            'linewidth': f'{prefix}.linewidth',
            }, cache=False)) # look up defaults
github lukelbd / proplot / proplot / axes.py View on Github external
The subplot row and column labels. If list, length must match
            the number of subplot rows, columns.
        figtitle, suptitle : str, optional
            The figure "super" title, centered between the left edge of
            the lefmost column of subplots and the right edge of the rightmost
            column of subplots, and automatically offset above figure titles.

            This is more sophisticated than matplotlib's builtin "super title",
            which is just centered between the figure edges and offset from
            the top edge.
        """
        # Figure patch (for some reason needs to be re-asserted even if
        # declared before figure is drawn)
        # Look into `~matplotlib.axes.SubplotBase.is_last_row` and
        # `~matplotlib.axes.SubplotBase.is_first_column` methods.
        kw = rc.fill({'facecolor':'figure.facecolor'})
        self.figure.patch.update(kw)

        # Super title and labels
        # NOTE: These are actually *figure-wide* settings, but that line seems
        # to get 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.
        fig = self.figure # the figure
        suptitle = figtitle or suptitle
        kw = rc.fill({
            'fontsize':   'suptitle.fontsize',
            'weight':     'suptitle.weight',
            'color':      'suptitle.color',
            'fontfamily': 'font.family'
            })
        if suptitle or kw: # if either is not None or non-empty
github lukelbd / proplot / proplot / wrappers.py View on Github external
y1 = 0.5 + interval * len(pairs) / 2 - (i + 1) * interval
                y2 = 0.5 + interval * len(pairs) / 2 - i * interval
            ymin = min(y1, _notNone(ymin, y1))
            ymax = max(y2, _notNone(ymax, y2))
            # Draw legend
            bbox = mtransforms.Bbox([[0, y1], [1, y2]])
            leg = mlegend.Legend(
                self, *zip(*ipairs), loc=loc, ncol=len(ipairs),
                bbox_transform=self.transAxes, bbox_to_anchor=bbox,
                frameon=False, **kwargs)
            legs.append(leg)

    # Add legends manually so matplotlib does not remove old ones
    # Also apply override settings
    kw_handle = {}
    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)
    for key, value in (
        ('color', color),
        ('marker', marker),
        ('linewidth', lw),
        ('linewidth', linewidth),
        ('markersize', markersize),
        ('linestyle', linestyle),
github lukelbd / proplot / proplot / axes.py View on Github external
kw_ticks = {}
                else:
                    kw_ticks.pop('visible', None) # invalid setting
                if ticklen is not None:
                    if which=='major':
                        kw_ticks['size'] = utils.units(ticklen, 'pt')
                    else:
                        kw_ticks['size'] = utils.units(ticklen, 'pt') * rc.get('ticklenratio')
                # Grid style and toggling
                if igrid is not None:
                    axis.grid(igrid, which=which) # toggle with special global props
                if which=='major':
                    kw_grid = rc.fill(grid_dict('grid'))
                else:
                    kw_major = kw_grid
                    kw_grid = rc.fill(grid_dict('gridminor'))
                    kw_grid.update({key:value for key,value in kw_major.items() if key not in kw_grid})
                # Changed rc settings
                axis.set_tick_params(which=which, **kw_grid, **kw_ticks)

            # Tick and ticklabel properties that apply to both major and minor
            # * Weird issue seems to cause set_tick_params to reset/forget that the grid
            #   is turned on if you access tick.gridOn directly, instead of passing through tick_params.
            #   Since gridOn is undocumented feature, don't use it. So calling _format_axes() a second time will remove the lines
            # * Can specify whether the left/right/bottom/top spines get ticks; sides will be
            #   group of left/right or top/bottom
            # * Includes option to draw spines but not draw ticks on that spine, e.g.
            #   on the left/right edges
            if not isinstance(self, mproj.PolarAxes):
                kw = {}
                translate = {None: None, 'both': sides, 'neither': (), 'none': ()}
                if bounds is not None and tickloc not in sides:
github lukelbd / proplot / proplot / axes.py View on Github external
def format_partial(self, patch_kw={}, **kwargs):
        # Documentation inherited from ProjectionAxes
        grid, latmax, lonlim, latlim, lonlocator, latlocator, labels, lonlabels, latlabels, kwargs = \
                super().format_partial(**kwargs)
        if lonlim is not None or latlim is not None:
            warnings.warn('You cannot "zoom into" a basemap projection after creating it. Pass a proj_kw dictionary in your call to subplots, with any of the following basemap keywords: llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, llcrnrx, llcrnry, urcrnrx, urcrnry, width, or height.')

        # Map boundary
        # * First have to *manually replace* the old boundary by just deleting
        #   the original one
        # * If boundary is drawn successfully should be able to call
        #   self.m._mapboundarydrawn.set_visible(False) and edges/fill color disappear
        # * For now will enforce that map plots *always* have background whereas
        #   axes plots can have transparent background
        kw_face = rc.fill({
            'facecolor': 'map.facecolor'
            })
        kw_face.update(patch_kw)
        kw_edge = rc.fill({
            'linewidth': 'map.linewidth',
            'edgecolor': 'map.edgecolor'
            })
        self.axesPatch = self.patch # bugfix or something
        if self.m.projection in self._proj_non_rectangular:
            self.patch.set_alpha(0) # make patch invisible
            if not self.m._mapboundarydrawn:
                p = self.m.drawmapboundary(ax=self) # set fill_color to 'none' to make transparent
            else:
                p = self.m._mapboundarydrawn
            p.update({**kw_face, **kw_edge})
            p.set_rasterized(False) # not sure about this; might be rasterized
github lukelbd / proplot / proplot / axes.py View on Github external
"""
        # Figure patch (for some reason needs to be re-asserted even if
        # declared before figure is drawn)
        # Look into `~matplotlib.axes.SubplotBase.is_last_row` and
        # `~matplotlib.axes.SubplotBase.is_first_column` methods.
        kw = rc.fill({'facecolor':'figure.facecolor'})
        self.figure.patch.update(kw)

        # Super title and labels
        # NOTE: These are actually *figure-wide* settings, but that line seems
        # to get 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.
        fig = self.figure # the figure
        suptitle = figtitle or suptitle
        kw = rc.fill({
            'fontsize':   'suptitle.fontsize',
            'weight':     'suptitle.weight',
            'color':      'suptitle.color',
            'fontfamily': 'font.family'
            })
        if suptitle or kw: # if either is not None or non-empty
            fig._setup_suptitle(suptitle, **kw)
        kw = rc.fill({
            'fontsize':   'rowlabel.fontsize',
            'weight':     'rowlabel.weight',
            'color':      'rowlabel.color',
            'fontfamily': 'font.family'
            })
        if rowlabels or kw:
            fig._setup_labels(self, rowlabels, rows=True, **kw)
        kw = rc.fill({
github lukelbd / proplot / proplot / axes.py View on Github external
inside or outside the axes. The default is center, outside."""
        # Apply rc settings
        prefix = 'abc' if abc else 'title'
        kwargs = rc.fill({
            'fontsize':   f'{prefix}.fontsize',
            'weight':     f'{prefix}.weight',
            'color':      f'{prefix}.color',
            'fontfamily': 'font.family'
            })
        if loc is None:
            loc = rc[f'{prefix}.loc']
        if loc is None:
            return kwargs

        # Add border props if we are moving it
        kwargs.update(rc.fill({
            'border':    f'{prefix}.border',
            'linewidth': f'{prefix}.linewidth',
            }, cache=False)) # look up defaults

        # Get coordinates
        ypad = rc.get('axes.titlepad')/(72*self.height) # to inches --> to axes relative
        xpad = rc.get('axes.titlepad')/(72*self.width)  # why not use the same for x?
        if isinstance(loc, str): # coordinates
            # Get horizontal position
            if loc in ('c','uc','lc','center','upper center','lower center'):
                x, ha = 0.5, 'center'
            elif loc in ('l','ul','ll','left','upper left','lower left'):
                x, ha = 1.5*xpad*(loc not in ('l','left')), 'left'
            elif loc in ('r','ur','lr','right','upper right','lower right'):
                x, ha = 1 - 1.5*xpad*(loc not in ('r','right')), 'right'
            else:
github lukelbd / proplot / proplot / axes.py View on Github external
# Super title and labels
        # NOTE: These are actually *figure-wide* settings, but that line seems
        # to get 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.
        fig = self.figure # the figure
        suptitle = figtitle or suptitle
        kw = rc.fill({
            'fontsize':   'suptitle.fontsize',
            'weight':     'suptitle.weight',
            'color':      'suptitle.color',
            'fontfamily': 'font.family'
            })
        if suptitle or kw: # if either is not None or non-empty
            fig._setup_suptitle(suptitle, **kw)
        kw = rc.fill({
            'fontsize':   'rowlabel.fontsize',
            'weight':     'rowlabel.weight',
            'color':      'rowlabel.color',
            'fontfamily': 'font.family'
            })
        if rowlabels or kw:
            fig._setup_labels(self, rowlabels, rows=True, **kw)
        kw = rc.fill({
            'fontsize':   'collabel.fontsize',
            'weight':     'collabel.weight',
            'color':      'collabel.color',
            'fontfamily': 'font.family'
            })
        if collabels or kw:
            fig._setup_labels(self, collabels, rows=False, **kw)