figure

figure(**kwargs)[source]

Create an empty figure. Subplots can be subsequently added using add_subplot or subplots. This command is analogous to matplotlib.pyplot.figure.

Parameters
  • refnum (int, optional) – The reference subplot number. The refwidth, refheight, and refaspect keyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in the auto_layout. The default is the first subplot created in the figure.

  • refaspect (float or 2-tuple of float, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, indicates the (width, height). Ignored if both figwidth and figheight or both refwidth and refheight were passed.

  • refwidth, refheight (unit-spec, optional) – The width, height of the reference subplot. Default is rc['subplots.refwidth'] = 2.5. If float, units are inches. If string, interpreted by units. Ignored if figwidth, figheight, or figsize was passed. If you specify just one, refaspect will be respected.

  • ref, aspect, axwidth, axheight – Aliases for refnum, refaspect, refwidth, refheight. These may be deprecated in a future release.

  • figwidth, figheight (unit-spec, optional) – The figure width and height. Default behavior is to use refwidth. If float, units are inches. If string, interpreted by units. If you specify just one, refaspect will be respected.

  • width, height – Aliases for figwidth, figheight.

  • figsize (2-tuple, optional) – Tuple specifying the figure (width, height).

  • sharex, sharey, share ({0, False, 1, 'labels', 'labs', 2, 'limits', 'lims', 3, True, 4, 'all'}, optional) – The axis sharing “level” for the x axis, y axis, or both axes. Default is rc['subplots.share'] = True. Options are as follows:

    • 0 or False: No axis sharing. This also sets the default spanx and spany values to False.

    • 1 or 'labels' or 'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.

    • 2 or 'limits' or 'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.

    • 3 or True: As above but only show the tick labels on the bottommost row and leftmost column of subplots.

    • 4 or 'all': As above but also share the axis limits, scales, and tick locations between subplots not in the same row or column.

  • spanx, spany, span (bool or {0, 1}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default is False if sharex, sharey, or share are 0 or False, rc['subplots.span'] = True otherwise. When True, a single, centered axis label is used for all axes with bottom and left edges in the same row or column. This can considerably redundancy in your figure.

    “Spanning” labels integrate with “shared” axes. For example, for a 3-row, 3-column figure, with sharey > 1 and spany=1, your figure will have 1 ylabel instead of 9.

  • alignx, aligny, align (bool or {0, 1}, optional) – Whether to “align” axis labels for the x axis, y axis, or both axes. Aligned labels always appear in the same row or column. This Only has an effect when spanx, spany, or span are False. Default is rc['subplots.align'] = False.

  • left, right, top, bottom (unit-spec, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • wspace, hspace, space (unit-spec, optional) – The fixed space between grid columns, rows, or both. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • tight (bool, optional) – Whether to have auto_layout include tight layout adjustments. Default is rc['subplots.tight'] = True. If you manually specified a spacing in the call to subplots, it will be used to override the tight layout spacing. For example, with left=1, the left margin is set to 1 em-width, while the remaining margin widths are calculated automatically.

  • wequal, hequal, equal (bool, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default is False. Ignored if rc.tight is False.

  • outerpad (unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • includepanels (bool, optional) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning the spanx x axis labels and spany y axis labels along the sides of the subplot grid. Default is False.

  • mathtext_fallback (bool or str, optional) – Apply this rc['mathtext.fallback'] value when drawing the figure. If True or string, unavailable glyphs are replaced with a glyph from a fallback font (Computer Modern by default). Otherwise, they are replaced with the “¤” dummy character. For details see this mathtext tutorial.

  • journal (str, optional) – String corresponding to an academic journal standard used to control the figure width figwidth and, if specified, the figure height figheight. See the below table. Feel free to add to this table by submitting a pull request.

    Key

    Size description

    Organization

    'aaas1'

    1-column

    American Association for the Advancement of Science (e.g. Science)

    'aaas2'

    2-column

    'agu1'

    1-column

    American Geophysical Union

    'agu2'

    2-column

    'agu3'

    full height 1-column

    'agu4'

    full height 2-column

    'ams1'

    1-column

    American Meteorological Society

    'ams2'

    small 2-column

    'ams3'

    medium 2-column

    'ams4'

    full 2-column

    'nat1'

    1-column

    Nature Research

    'nat2'

    2-column

    'pnas1'

    1-column

    Proceedings of the National Academy of Sciences

    'pnas2'

    2-column

    'pnas3'

    landscape page

Other Parameters

**kwargs – Passed to matplotlib.figure.Figure.