Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
d['axes.linewidth'] = linewidth
d['xtick.major.width'] = linewidth
d['xtick.minor.width'] = linewidth
d['ytick.major.width'] = linewidth
d['ytick.minor.width'] = linewidth
d['grid.linewidth'] = linewidth
if linestyle:
d['grid.linestyle'] = linestyle
rcParams.update(d)
return rcParams
# element_rect themeables
class legend_key(themeable):
"""
Legend key background
Parameters
----------
theme_element : element_rect
"""
def apply_figure(self, figure):
super(legend_key, self).apply_figure(figure)
with suppress(KeyError):
# list of lists
all_drawings = figure._themeable['legend_key']
for drawings in all_drawings:
for da in drawings:
da.patch.set(**self.properties)
Parameters
----------
theme_element : str in ``['in', 'out', 'inout']``
- ``in`` - ticks inside the panel
- ``out`` - ticks outside the panel
- ``inout`` - ticks inside and outside the panel
"""
@property
def rcParams(self):
rcParams = super(axis_ticks_direction_x, self).rcParams
rcParams['xtick.direction'] = self.properties['value']
return rcParams
class axis_ticks_direction_y(themeable):
"""
y-axis tick direction
Parameters
----------
theme_element : str in ``['in', 'out', 'inout']``
- ``in`` - ticks inside the panel
- ``out`` - ticks outside the panel
- ``inout`` - ticks inside and outside the panel
"""
@property
def rcParams(self):
rcParams = super(axis_ticks_direction_y, self).rcParams
rcParams['ytick.direction'] = self.properties['value']
return rcParams
super(plot_title, self).apply_figure(figure)
properties = self.properties.copy()
with suppress(KeyError):
del properties['margin']
with suppress(KeyError):
text = figure._themeable['plot_title']
text.set(**properties)
def blank_figure(self, figure):
super(plot_title, self).blank_figure(figure)
with suppress(KeyError):
text = figure._themeable['plot_title']
text.set_visible(False)
class strip_text_x(themeable):
"""
Facet labels along the horizontal axis
Parameters
----------
theme_element : element_text
"""
def apply_figure(self, figure):
super(strip_text_x, self).apply_figure(figure)
properties = self.properties.copy()
with suppress(KeyError):
del properties['margin']
with suppress(KeyError):
texts = figure._themeable['strip_text_x']
for text in texts:
text.set(**properties)
with suppress(KeyError):
del d['facecolor']
if 'edgecolor' in d and 'alpha' in d:
d['edgecolor'] = to_rgba(d['edgecolor'], d['alpha'])
del d['alpha']
ax.patch.set(**d)
def blank(self, ax):
super(panel_border, self).blank(ax)
ax.patch.set_linewidth(0)
class plot_background(themeable):
"""
Plot background
Parameters
----------
theme_element : element_rect
"""
def apply_figure(self, figure):
figure.patch.set(**self.properties)
def blank_figure(self, figure):
super(plot_background, self).blank_figure(figure)
_blankout_rect(figure.patch)
class strip_background_x(themeable):
"""
class legend_box_just(themeable):
"""
Justification of legend boxes
Parameters
----------
theme_element : str
One of *left*, *right*, *center*, *top* or *bottom*
depending the value of :class:`legend_box`.
"""
class legend_direction(themeable):
"""
Layout items in the legend
Parameters
----------
theme_element : str in ``['vertical', 'horizontal']``
Vertically or horizontally
"""
class legend_key_width(themeable):
"""
Legend key background width
Parameters
----------
strip_margin=None,
**kwargs):
self.themeables = Themeables()
self.complete = complete
# This is set when the figure is created,
# it is useful at legend drawing time and
# when applying the theme.
self.figure = None
if complete:
self._rcParams = deepcopy(default_rcparams)
else:
self._rcParams = {}
# Themeables
official_themeables = themeable.registry()
it = ((name, element) for name, element in locals().items()
if element is not None and name in official_themeables)
new = themeable.from_class_name
for name, element in it:
self.themeables[name] = new(name, element)
# Unofficial themeables (for extensions)
for name, element in kwargs.items():
self.themeables[name] = new(name, element)
all_drawings = figure._themeable['legend_key']
for drawings in all_drawings:
for da in drawings:
da.patch.set(**self.properties)
def blank_figure(self, figure):
super(legend_key, self).blank_figure(figure)
with suppress(KeyError):
# list of lists
all_drawings = figure._themeable['legend_key']
for drawings in all_drawings:
for da in drawings:
_blankout_rect(da.patch)
class legend_background(themeable):
"""
Legend background
Parameters
----------
theme_element : element_rect
"""
def apply_figure(self, figure):
super(legend_background, self).apply_figure(figure)
# anchored offset box
with suppress(KeyError):
aob = figure._themeable['legend_background']
aob.patch.set(**self.properties)
if self.properties:
aob._drawFrame = True
# some small sensible padding
text = figure._themeable['axis_title_y']
text.set_visible(False)
class axis_title(axis_title_x, axis_title_y):
"""
Axis labels
Parameters
----------
theme_element : element_text
"""
pass
class legend_title(themeable):
"""
Legend title
Parameters
----------
theme_element : element_text
"""
def apply_figure(self, figure):
super(legend_title, self).apply_figure(figure)
properties = self.properties.copy()
with suppress(KeyError):
del properties['margin']
with suppress(KeyError):
textareas = figure._themeable['legend_title']
for ta in textareas:
ta._text.set(**properties)
Vertical major grid lines
Parameters
----------
theme_element : element_line
"""
def apply(self, ax):
super(panel_grid_major_x, self).apply(ax)
ax.xaxis.grid(which='major', **self.properties)
def blank(self, ax):
super(panel_grid_major_x, self).blank(ax)
ax.grid(False, which='major', axis='x')
class panel_grid_major_y(themeable):
"""
Horizontal major grid lines
Parameters
----------
theme_element : element_line
"""
def apply(self, ax):
super(panel_grid_major_y, self).apply(ax)
ax.yaxis.grid(which='major', **self.properties)
def blank(self, ax):
super(panel_grid_major_y, self).blank(ax)
ax.grid(False, which='major', axis='y')
*top* or *bottom*.
"""
class legend_entry_spacing_x(themeable):
"""
Horizontal spacing between two entries in a legend
Parameters
----------
theme_element : float
Size in points
"""
class legend_entry_spacing_y(themeable):
"""
Vertical spacing between two entries in a legend
Parameters
----------
theme_element : float
Size in points
"""
class legend_entry_spacing(legend_entry_spacing_x, legend_entry_spacing_y):
"""
Spacing between two entries in a legend
Parameters
----------