美文网首页
python proplot Configuring ProP

python proplot Configuring ProP

作者: 晨阳ouc | 来源:发表于2021-02-11 14:38 被阅读0次

    A special object named rc, belonging to the RcConfigurator class, is created on import. This is your one-stop shop for working with builtin matplotlib global settings and the global settings added by proplot. Global settings can be changed on-the-fly using the rc object as follows:

    import proplot as plot

    plot.rc.name = value

    plot.rc['name'] = value

    plot.rc.update(name1=value1, name2=value2)

    plot.rc.update({'name1': value1, 'name2': value2})

    To apply settings to a particular axes, pass the setting to the format command using either of the following approaches:

    import proplot as plot

    fig, ax = plot.subplots()

    ax.format(name1=value1, name2=value2)

    ax.format(rc_kw={'name1': value1, 'name2': value2})

    In all of these examples, if the setting name contains dots, you can simply omit the dots. For example, to change the rc[‘title.loc’] property, the following approaches are valid:

    import proplot as plot

    # Apply globally

    plot.rc.titleloc = value

    plot.rc.update(titleloc=value)

    # Apply locally

    fig, ax = plot.subplots()ax.format(titleloc=value)

    Matplotlib settings

    Details on the matplotlib settings can be found on this page.

    ProPlot settings

    ProPlot adds several settings to customize things not covered by matplotlib’s builtin settings. Some of these settings may be more accurately described as “meta-settings”, as they change several matplotlib settings at once (for example, rc.linewidth changes axes edge widths, gridline widths, and tick widths). Other settings are for specific features controlled by ProPlot, like a-b-c labels.

    The subplots category controls the default layout for figures and axes. The abc, title, and tick categories control a-b-c label, title, and axis tick label settings. The suptitle, leftlabel, toplabel, rightlabel, and bottomlabel categories control figure title and edge label settings. There are two new additions to the image category, and the new colorbar category controls inset and outer colorbar properties. There is also a new gridminor category for minor gridline settings (note that gridminor inherits grid properties when they are changed). Finally, the land, ocean, rivers, lakes, borders, and innerborders categories control various GeoAxes settings.

    KeyDescription

    styleThe default matplotlib stylesheetname. IfNone, a custom proplot style is used. If 'default', the default matplotlib style is used.

    abcBoolean, whether to draw a-b-c labels by default.

    abc.borderBoolean, indicates whether to draw a white border around a-b-c labels when rc[‘abc.loc’]is inside the axes.

    abc.borderwidthWidth of the white border around a-b-c labels.

    abc.colora-b-c label color.

    abc.loca-b-c label position. For options, see the title location table.

    abc.sizea-b-c label font size.

    abc.stylea-b-c label style. Must be string containing the character a or A, for example 'a.' or '(A)'.

    abc.weighta-b-c label font weight.

    autoformatWhether to automatically apply labels from pandas.Series,pandas.DataFrame, andxarray.DataArrayobjects passed to plotting functions.

    alphaThe opacity of the background axes patch.

    axes.alphaThe opacity of the background axes patch.

    formatter.timerotationFloat, indicates the default x axis tick label rotation for datetime tick labels.

    formatter.zerotrimBoolean, indicates whether trailing decimal zeros are trimmed on tick labels.

    formatter.limitsAlias for rc[‘axes.formatter.limits’].

    formatter.use_localeAlias for rc[‘axes.formatter.use_locale’].

    formatter.use_mathtextAlias for rc[‘axes.formatter.use_mathtext’].

    formatter.min_exponentAlias for rc[‘axes.formatter.min_exponent’].

    formatter.use_offsetAlias for rc[‘axes.formatter.useOffset’].

    formatter.offset_thresholdAlias for rc[‘axes.formatter.offset_threshold’].

    bordersBoolean, toggles country border lines on and off.

    borders.colorLine color for country borders.

    borders.linewidthLine width for country borders.

    borders.zorderZ-order for country border lines.

    bottomlabel.colorFont color for column labels on the bottom of the figure.

    bottomlabel.sizeFont size for column labels on the bottom of the figure.

    bottomlabel.weightFont weight for column labels on the bottom of the figure.

    cartopy.autoextentIf False (the default), the projection extent is no longer automatically adjusted based on plotted content. See the user guidefor details.

    coastBoolean, toggles coastline lines on and off.

    coast.colorLine color for coast lines.

    coast.linewidthLine width for coast lines.

    colorbar.extendLength of rectangular or triangular “extensions” for panel colorbars. Interpted by units.

    colorbar.framealphaOpacity for inset colorbar frames.

    colorbar.frameonBoolean, indicates whether to draw a frame behind inset colorbars.

    colorbar.gridBoolean, indicates whether to draw borders between each level of the colorbar.

    colorbar.insetextendLength of rectangular or triangular “extensions” for inset colorbars. Interpted by units.

    colorbar.insetlengthLength of inset colorbars. Interpted by units.

    colorbar.insetpadPadding between axes edge and inset colorbars.

    colorbar.insetwidthWidth of inset colorbars. Interpted by units.

    colorbar.lengthLength of outer colorbars.

    colorbar.locInset colorbar location. For options, see the location table.

    colorbar.widthWidth of outer colorbars. Interpted by units.

    cmapThe default sequential colormap.

    colorThe color of axis spines, tick marks, tick labels, and labels.

    cycleThe name of the color cycle used for plot elements like lines.

    facecolorThe color of the background axes patch.

    font.nameAlias for rc[‘font.family’]. The default is'sans-serif'.

    gridBoolean, toggles major grid lines on and off.

    grid.belowAlias for rc[‘axes.axisbelow’]. IfFalse, draw gridlines on top of everything. If True, underneath everything. If 'line', underneath patches only.

    grid.dmslabelsBoolean, indicates whether to use degrees-minutes-seconds rather than decimals for gridline labels on CartopyAxes.

    grid.padPadding in points between map boundary edge and longitude and latitude labels for GeoAxes.

    grid.labelsBoolean, indicates whether to label the longitude and latitude gridlines in GeoAxes.

    grid.labelsizeFont size for longitude and latitude gridline labels in GeoAxes.

    grid.labelweightFont weight for longitude and latitude gridline labels in GeoAxes.

    grid.labelcolorFont color for longitude and latitude gridline labels in GeoAxes.

    grid.latinlineWhether to use inline labels for CartopyAxeslatitude gridlines.

    grid.loninlineWhether to use inline labels for CartopyAxeslongitude gridlines.

    grid.nstepsNumber of interpolation steps used to draw cartopy gridlines.

    grid.ratioRatio of minor gridline width to major gridline width.

    grid.rotatelabelsBoolean, indicates whether to rotate longitude and latitude CartopyAxesgridline labels.

    gridminorBoolean, toggles minor grid lines on and off.

    gridminor.alphaMinor gridline transparency.

    gridminor.colorMinor gridline color.

    gridminor.latstepLatitude gridline interval for GeoAxeswith global extent.

    gridminor.linestyleMinor gridline style.

    gridminor.linewidthMinor gridline width.

    gridminor.lonstepInterval for GeoAxeslongitude gridlines in degrees.

    image.edgefixWhether to fix the white-lines-between-filled-contoursandwhite-lines-between-pcolor-rectanglesissues.

    image.levelsDefault number of levels for pcolormesh and contourf plots.

    inlinefmtThe inline backend figure format or list thereof. Valid formats include 'svg', 'pdf', 'retina', 'png', and jpeg.

    innerbordersBoolean, toggles internal political border lines (e.g. states and provinces) on and off.

    innerborders.colorLine color for internal political borders.

    innerborders.linewidthLine width for internal political borders.

    innerborders.zorderZ-order for internal border lines.

    lakesBoolean, toggles lake patches on and off.

    lakes.colorFace color for lake patches.

    lakes.zorderZ-order for lake patches.

    landBoolean, toggles land patches on and off.

    land.colorFace color for land patches.

    land.zorderZ-order for land patches.

    leftlabel.colorFont color for row labels on the left-hand side.

    leftlabel.sizeFont size for row labels on the left-hand side.

    leftlabel.weightFont weight for row labels on the left-hand side.

    linewidthThickness of axes spines and major tick lines.

    lutThe number of colors to put in the colormap lookup table.

    marginThe margin of space between axes edges and objects plotted inside the axes if xlim and ylim are unset.

    negcolorThe color for negative bars and shaded areas when using negpos=True. See also rc.poscolor.

    poscolorThe color for positive bars and shaded areas when using negpos=True. See also rc.negcolor.

    oceanBoolean, toggles ocean patches on and off.

    ocean.colorFace color for ocean patches.

    ocean.zorderZ-order for ocean patches.

    resoResolution for GeoAxesgeographic features. Must be one of'lo', 'med', 'hi', 'x-hi', or 'xx-hi'.

    rightlabel.colorFont color for row labels on the right-hand side.

    rightlabel.sizeFont size for row labels on the right-hand side.

    rightlabel.weightFont weight for row labels on the right-hand side.

    riversBoolean, toggles river lines on and off.

    rivers.colorLine color for river lines.

    rivers.linewidthLine width for river lines.

    rivers.zorderZ-order for river lines.

    subplots.alignWhether to align axis labels during draw. See aligning labels.

    subplots.axpadPadding between adjacent subplots. Interpted by units.

    subplots.axwidthDefault width of each axes. Interpted by units.

    subplots.padPadding around figure edge. Interpted by units.

    subplots.panelpadPadding between subplots and panels, and between stacked panels. Interpted by units.

    subplots.panelwidthWidth of side panels. Interpted by units.

    subplots.shareThe axis sharing level, one of 0, 1, 2, or 3. See the user guidefor details.

    subplots.spanBoolean, toggles spanning axis labels. See subplotsfor details.

    subplots.tightBoolean, indicates whether to auto-adjust figure bounds and subplot spacings.

    suptitle.colorFigure title color.

    suptitle.sizeFigure title font size.

    suptitle.weightFigure title font weight.

    text.labelsizeMeta setting that changes the label-like sizes tick.labelsize, axes.labelsize, legend.fontsize, and grid.labelsize. Default is 'medium', i.e. the value of rc[‘font.size’](seethis list of valid font sizes).

    text.titlesizeMeta setting that changes the title-like sizes abc.size, title.size, suptitle.size, and row and column label sizes like leftlabel.size. Default is 'med-large', i.e. 1.1 times rc[‘font.size’](seethis list of valid font sizes).

    tick.colorMajor and minor tick color.

    tick.dirMajor and minor tick direction. Must be one of 'out', 'in', or 'inout'.

    tick.labelcolorAxis tick label color. Mirrors the axis label rc[‘axes.labelcolor’]setting.

    tick.labelsizeAxis tick label font size. Mirrors the axis label rc[‘axes.labelsize’]setting.

    tick.labelweightAxis tick label font weight. Mirrors the axis label rc[‘axes.labelweight’]setting.

    tick.lenLength of major ticks in points.

    tick.lenratioRatio of minor tickline length to major tickline length.

    tick.minorBoolean, toggles minor ticks on and off.

    tick.padPadding between ticks and tick labels in points.

    tick.ratioRatio of minor tickline width to major tickline width.

    title.borderBoolean, indicates whether to draw a white border around titles when rc[‘title.loc’]is inside the axes.

    title.borderwidthWidth of the white border around titles.

    title.colorAxes title color.

    title.locTitle position. For options, see the title location table.

    title.padPadding between axes and outer titles or a-b-c labels in arbitrary units. Alias for rc[‘axes.titlepad’].

    title.sizeAxes title font size.

    title.weightAxes title font weight.

    toplabel.colorFont color for column labels on the top of the figure.

    toplabel.sizeFont size for column labels on the top of the figure.

    toplabel.weightFont weight for column labels on the top of the figure.

    The .proplotrc file

    When you install ProPlot for the first time, a .proplotrc file is generated and placed in your home directory. This is just like the matplotlibrc file, but for changing both ProPlot and matplotlib settings. The syntax is basically the same as the matplotlibrc syntax.

    To change the default global settings, simply edit and uncomment the entries listed in this file. You can also change the settings for individual projects by placing a .proplotrc file in the same directory as your python scripts or jupyter notebooks, or in an arbitrary parent directory. As an example, a .proplotrc file containing the default settings is shown below.

    #--------------------------------------------------------------------

    # Use this file to change the default proplot and matplotlib settings

    # The syntax is identical to matplotlibrc syntax. For details see:

    # https://proplot.readthedocs.io/en/latest/configuration.html

    # https://matplotlib.org/3.1.1/tutorials/introductory/customizing

    #--------------------------------------------------------------------

    # ProPlot settings

    style:                      None

    abc:                        False

    abc.border:                 True

    abc.borderwidth:            1.5

    abc.color:                  black

    abc.loc:                    l

    abc.size:                   med-large

    abc.style:                  a

    abc.weight:                 bold

    autoformat:                 True

    alpha:                      1.0

    axes.alpha:                 1.0

    formatter.timerotation:     90

    formatter.zerotrim:         True

    formatter.limits:           -5, 6

    formatter.use_locale:       False

    formatter.use_mathtext:     False

    formatter.min_exponent:     0

    formatter.use_offset:       True

    formatter.offset_threshold: 4

    borders:                    False

    borders.color:              black

    borders.linewidth:          0.6

    borders.zorder:             2

    bottomlabel.color:          black

    bottomlabel.size:           med-large

    bottomlabel.weight:         bold

    cartopy.autoextent:         False

    coast:                      False

    coast.color:                black

    coast.linewidth:            0.6

    colorbar.extend:            1.3em

    colorbar.framealpha:        0.8

    colorbar.frameon:           True

    colorbar.grid:              False

    colorbar.insetextend:       1em

    colorbar.insetlength:       8em

    colorbar.insetpad:          0.5em

    colorbar.insetwidth:        1.2em

    colorbar.length:            1

    colorbar.loc:               right

    colorbar.width:             1.5em

    cmap:                       fire

    color:                      black

    cycle:                      colorblind

    facecolor:                  white

    font.name:                  sans-serif

    grid:                       True

    grid.below:                 line

    grid.dmslabels:             True

    grid.pad:                   5

    grid.labels:                False

    grid.labelsize:             medium

    grid.labelweight:           normal

    grid.labelcolor:            black

    grid.latinline:             False

    grid.loninline:             False

    grid.nsteps:                250

    grid.ratio:                 0.5

    grid.rotatelabels:          False

    gridminor:                  False

    gridminor.alpha:            0.11

    gridminor.color:            black

    gridminor.latstep:          10

    gridminor.linestyle:        -

    gridminor.linewidth:        0.3

    gridminor.lonstep:          20

    image.edgefix:              True

    image.levels:               11

    inlinefmt:                  retina

    innerborders:               False

    innerborders.color:         black

    innerborders.linewidth:     0.6

    innerborders.zorder:        2

    lakes:                      False

    lakes.color:                w

    lakes.zorder:               1

    land:                       False

    land.color:                 black

    land.zorder:                1

    leftlabel.color:            black

    leftlabel.size:             med-large

    leftlabel.weight:           bold

    linewidth:                  0.6

    lut:                        256

    margin:                     0.05

    negcolor:                   blue7

    poscolor:                   red7

    ocean:                      False

    ocean.color:                w

    ocean.zorder:               1

    reso:                       lo

    rightlabel.color:           black

    rightlabel.size:            med-large

    rightlabel.weight:          bold

    rivers:                     False

    rivers.color:               black

    rivers.linewidth:           0.6

    rivers.zorder:              2

    subplots.align:             False

    subplots.axpad:             1em

    subplots.axwidth:           20em

    subplots.pad:               0.5em

    subplots.panelpad:          0.5em

    subplots.panelwidth:        4em

    subplots.share:             3

    subplots.span:              True

    subplots.tight:             True

    suptitle.color:             black

    suptitle.size:              med-large

    suptitle.weight:            bold

    text.labelsize:             medium

    text.titlesize:             med-large

    tick.color:                 black

    tick.dir:                   out

    tick.labelcolor:            black

    tick.labelsize:             medium

    tick.labelweight:           normal

    tick.len:                   4.0

    tick.lenratio:              0.5

    tick.minor:                 True

    tick.pad:                   2.0

    tick.ratio:                 0.8

    title.border:               True

    title.borderwidth:          1.5

    title.color:                black

    title.loc:                  c

    title.pad:                  5.0

    title.size:                 med-large

    title.weight:               normal

    toplabel.color:             black

    toplabel.size:              med-large

    toplabel.weight:            bold

    # Matplotlib settings

    axes.axisbelow:              line

    axes.formatter.use_mathtext: False

    axes.grid:                   True

    axes.grid.which:             major

    axes.labelpad:               4.0

    axes.labelsize:              medium

    axes.labelweight:            normal

    axes.linewidth:              0.6

    axes.titlepad:               5.0

    axes.titlesize:              med-large

    axes.titleweight:            normal

    axes.xmargin:                0.05

    axes.ymargin:                0.05

    figure.autolayout:           False

    figure.dpi:                  100

    figure.facecolor:            '#f2f2f2'

    figure.titlesize:            med-large

    figure.titleweight:          bold

    font.serif:                  TeX Gyre Schola, TeX Gyre Bonum, TeX Gyre Termes, TeX Gyre Pagella, DejaVu Serif, Bitstream Vera Serif, Computer Modern Roman, Bookman, Century Schoolbook L, Charter, ITC Bookman, New Century Schoolbook, Nimbus Roman No9 L, Palatino, Times New Roman, Times, Utopia, serif

    font.sans-serif:             TeX Gyre Heros, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Arial, Avenir, Fira Math, Frutiger, Geneva, Gill Sans, Helvetica, Lucid, Lucida Grande, Myriad Pro, Noto Sans, Roboto, Source Sans Pro, Tahoma, Trebuchet MS, Ubuntu, Univers, Verdana, sans-serif

    font.monospace:              TeX Gyre Cursor, DejaVu Sans Mono, Bitstream Vera Sans Mono, Computer Modern Typewriter, Andale Mono, Courier New, Courier, Fixed, Nimbus Mono L, Terminal, monospace

    font.cursive:                TeX Gyre Chorus, Apple Chancery, Felipa, Sand, Script MT, Textile, Zapf Chancery, cursive

    font.fantasy:                TeX Gyre Adventor, Avant Garde, Charcoal, Chicago, Comic Sans MS, Futura, Humor Sans, Impact, Optima, Western, xkcd, fantasy

    font.size:                   9.0

    grid.alpha:                  0.11

    grid.color:                  black

    grid.linestyle:              -

    grid.linewidth:              0.6

    hatch.color:                 black

    hatch.linewidth:             0.6

    image.cmap:                  fire

    lines.linestyle:             -

    lines.linewidth:             1.5

    lines.markersize:            6.0

    legend.borderaxespad:        0

    legend.borderpad:            0.5

    legend.columnspacing:        1.5

    legend.fancybox:             False

    legend.fontsize:             medium

    legend.framealpha:           0.8

    legend.handletextpad:        0.5

    mathtext.fontset:            custom

    mathtext.default:            regular

    patch.linewidth:             0.6

    savefig.bbox:                None

    savefig.directory:           

    savefig.dpi:                 1200

    savefig.facecolor:           white

    savefig.format:              pdf

    savefig.transparent:         True

    xtick.direction:             out

    xtick.labelsize:             medium

    xtick.major.pad:             2.0

    xtick.major.size:            4.0

    xtick.major.width:           0.6

    xtick.minor.pad:             2.0

    xtick.minor.size:            2.0

    xtick.minor.visible:         True

    xtick.minor.width:           0.48

    ytick.direction:             out

    ytick.labelsize:             medium

    ytick.major.pad:             2.0

    ytick.major.size:            4.0

    ytick.major.width:           0.6

    ytick.minor.pad:             2.0

    ytick.minor.size:            2.0

    ytick.minor.width:           0.48

    ytick.minor.visible:         True

    相关文章

      网友评论

          本文标题:python proplot Configuring ProP

          本文链接:https://www.haomeiwen.com/subject/sagdxltx.html