seaborn.plotting_context

优质
小牛编辑
139浏览
2023-12-01
seaborn.plotting_context(context=None, font_scale=1, rc=None)

Return a parameter dict to scale elements of the figure.

This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. The base context is “notebook”, and the other contexts are “paper”, “talk”, and “poster”, which are version of the notebook parameters scaled by .8, 1.3, and 1.6, respectively.

This function returns an object that can be used in a with statement to temporarily change the context parameters.

参数:context:dict, None, or one of {paper, notebook, talk, poster}

A dictionary of parameters or the name of a preconfigured set.

font_scale:float, optional

Separate scaling factor to independently scale the size of the font elements.

rc:dict, optional

Parameter mappings to override the values in the preset seaborn context dictionaries. This only updates parameters that are considered part of the context definition.

See also

set the matplotlib parameters to scale plot elementsreturn a dict of parameters defining a figure styledefine the color palette for a plot

Examples

>>> c = plotting_context("poster")

>>> c = plotting_context("notebook", font_scale=1.5)

>>> c = plotting_context("talk", rc={"lines.linewidth": 2})

>>> import matplotlib.pyplot as plt
>>> with plotting_context("paper"):
...     f, ax = plt.subplots()
...     ax.plot(x, y)