yellowbrick.style package¶
Submodules¶
yellowbrick.style.colors module¶
Colors and color helpers brought in from an alternate library. See https://bl.ocks.org/mbostock/5577023
-
class
yellowbrick.style.colors.
ColorMap
(colors='flatui', shuffle=False)[source]¶ Bases:
object
A helper for mapping categorical values to colors on demand.
-
colors
¶
-
-
yellowbrick.style.colors.
get_color_cycle
()[source]¶ Returns the current color cycle from matplotlib.
-
yellowbrick.style.colors.
resolve_colors
(num_colors=None, colormap=None, color=None)[source]¶ Resolves the colormap or the color list with the number of colors. See: https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py#L163
Parameters: num_colors : int or None
the number of colors in the cycle or colormap
colormap : str or None
the colormap used to create the sequence of colors
color : list or Non e
the list of colors to specifically use with the plot
yellowbrick.style.palettes module¶
-
yellowbrick.style.palettes.
color_palette
(palette=None, n_colors=None)[source]¶ Return a color palette object with color definition and handling.
Calling this function with
palette=None
will return the current matplotlib color cycle.This function can also be used in a
with
statement to temporarily set the color cycle for a plot or set of plots.Parameters: palette : None or str or sequence
Name of a palette or
None
to return the current palette. If a sequence the input colors are used but possibly cycled.Available palette names from
yellowbrick.colors.palettes
are:accent
dark
paired
pastel
bold
muted
colorblind
sns_colorblind
sns_deep
sns_muted
sns_pastel
sns_bright
sns_dark
flatui
n_colors : None or int
Number of colors in the palette. If
None
, the default will depend on howpalette
is specified. Named palettes default to 6 colors which allow the use of the names “bgrmyck”, though others do have more or less colors; therefore reducing the size of the list can only be done by specifying this parameter. Asking for more colors than exist in the palette will cause it to cycle.Returns: list(tuple)
Returns a ColorPalette object, which behaves like a list, but can be used as a context manager and possesses functions to convert colors.
See also
set_palette()
Set the default color cycle for all plots.
set_color_codes()
Reassign color codes like
"b"
,"g"
, etc. to colors from one of the yellowbrick palettes.colors.resolve_colors()
Resolve a color map or listed sequence of colors.
-
yellowbrick.style.palettes.
set_color_codes
(palette='accent')[source]¶ Change how matplotlib color shorthands are interpreted.
Calling this will change how shorthand codes like “b” or “g” are interpreted by matplotlib in subsequent plots.
Parameters: palette : str
Named yellowbrick palette to use as the source of colors.
See also
set_palette
- Color codes can also be set through the function that sets the matplotlib color cycle.
yellowbrick.style.rcmod module¶
Modifies the matplotlib rcParams in order to make yellowbrick more appealing. This has been modified from Seaborn’s rcmod.py: github.com/mwaskom/seaborn in order to alter the matplotlib rc dictionary on the fly.
NOTE: matplotlib 2.0 styles mean we can simply convert this to a stylesheet!
-
yellowbrick.style.rcmod.
set_aesthetic
(palette='yellowbrick', font='sans-serif', font_scale=1, color_codes=True, rc=None)[source]¶ Set aesthetic parameters in one step.
Each set of parameters can be set directly or temporarily, see the referenced functions below for more information.
Parameters: palette : string or sequence
Color palette, see
color_palette()
font : string
Font family, see matplotlib font manager.
font_scale : float, optional
Separate scaling factor to independently scale the size of the font elements.
color_codes : bool
If
True
andpalette
is a yellowbrick palette, remap the shorthand color codes (e.g. “b”, “g”, “r”, etc.) to the colors from this palette.rc : dict or None
Dictionary of rc parameter mappings to override the above.
-
yellowbrick.style.rcmod.
set_style
(style=None, rc=None)[source]¶ Set the aesthetic style of the plots.
This affects things like the color of the axes, whether a grid is enabled by default, and other aesthetic elements.
Parameters: style : dict, None, or one of {darkgrid, whitegrid, dark, white, ticks}
A dictionary of parameters or the name of a preconfigured set.
rc : dict, optional
Parameter mappings to override the values in the preset seaborn style dictionaries. This only updates parameters that are considered part of the style definition.
-
yellowbrick.style.rcmod.
set_palette
(palette, n_colors=None, color_codes=False)[source]¶ Set the matplotlib color cycle using a seaborn palette.
Parameters: palette : yellowbrick color palette | seaborn color palette (with
sns_
prepended)Palette definition. Should be something that
color_palette()
can process.n_colors : int
Number of colors in the cycle. The default number of colors will depend on the format of
palette
, see thecolor_palette()
documentation for more information.color_codes : bool
If
True
andpalette
is a seaborn palette, remap the shorthand color codes (e.g. “b”, “g”, “r”, etc.) to the colors from this palette.