pltutils¶
Collection of utility functions for matplotlib
Functions
cm2inch (*values) |
Convert from centimeter to inch |
colorbar ([mappable, cax, ax, label, powerlimits]) |
Custom colorbar with modified style and optional label |
despine ([trim]) |
Remove the top and right spines |
despine_all () |
Remove all spines, axes labels and ticks |
get_palette ([name, num_colors, start]) |
Get a color palette from matplotlib’s colormap database |
legend (*args[, reverse, facecolor, lw]) |
Custom legend with modified style and option to reverse label order |
respine () |
Redraw all spines, opposite of despine() |
set_palette ([name, num_colors, start]) |
Set the active color palette |
use_style ([style]) |
Shortcut for matplotlib.style.use() with pybinding style applied by default |
-
cm2inch
(*values)¶ Convert from centimeter to inch
Parameters: - *values
Returns: - tuple
Examples
>>> cm2inch(2.54, 5.08) (1.0, 2.0)
-
colorbar
(mappable=None, cax=None, ax=None, label='', powerlimits=(0, 0), **kwargs)¶ Custom colorbar with modified style and optional label
Changes default
pad
andaspect
argument values and turns on rasterization for a nicer looking colorbar with smaller size in vector formats (pdf, svg).Parameters: - label : str
Color data label.
- powerlimits : Tuple[int, int]
Sets size thresholds for scientific notation.
- mappable, cax, ax, **kwargs
Forwarded to
matplotlib.pyplot.colorbar()
.
-
despine
(trim=False)¶ Remove the top and right spines
Parameters: - trim : bool
Trim spines so that they don’t extend beyond the last major ticks.
-
despine_all
()¶ Remove all spines, axes labels and ticks
-
get_palette
(name=None, num_colors=8, start=0)¶ Get a color palette from matplotlib’s colormap database
Parameters: - name : str, optional
Name of the palette to get. If
None
, get the active palette.- num_colors : int
Number of colors to retrieve.
- start : int
Staring from this color number.
Returns: - List[color]
-
legend
(*args, reverse=False, facecolor='0.98', lw=0, **kwargs)¶ Custom legend with modified style and option to reverse label order
Parameters: - reverse : bool
Reverse the label order.
- facecolor : color
Legend background color.
- lw : float
Frame width.
- *args, **kwargs
Forwarded to
matplotlib.pyplot.legend()
.
-
set_palette
(name=None, num_colors=8, start=0)¶ Set the active color palette
Parameters: - name : str, optional
Name of the palette. If
None
, modify the active palette.- num_colors : int
Number of colors to retrieve.
- start : int
Staring from this color number.
-
use_style
(style=pb_style)¶ Shortcut for
matplotlib.style.use()
with pybinding style applied by defaultParameters: - style : dict
A matplotlib style specification.