MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _apply_params

Method _apply_params

lib/matplotlib/axis.py:320–375  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

318 raise NotImplementedError('Derived must override')
319
320 def _apply_params(self, **kwargs):
321 for name, target in [("gridOn", self.gridline),
322 ("tick1On", self.tick1line),
323 ("tick2On", self.tick2line),
324 ("label1On", self.label1),
325 ("label2On", self.label2)]:
326 if name in kwargs:
327 target.set_visible(kwargs.pop(name))
328 if any(k in kwargs for k in ['size', 'width', 'pad', 'tickdir']):
329 self._size = kwargs.pop('size', self._size)
330 # Width could be handled outside this block, but it is
331 # convenient to leave it here.
332 self._width = kwargs.pop('width', self._width)
333 self._base_pad = kwargs.pop('pad', self._base_pad)
334 # _apply_tickdir uses _size and _base_pad to make _pad, and also
335 # sets the ticklines markers.
336 self._apply_tickdir(kwargs.pop('tickdir', self._tickdir))
337 for line in (self.tick1line, self.tick2line):
338 line.set_markersize(self._size)
339 line.set_markeredgewidth(self._width)
340 # _get_text1_transform uses _pad from _apply_tickdir.
341 trans = self._get_text1_transform()[0]
342 self.label1.set_transform(trans)
343 trans = self._get_text2_transform()[0]
344 self.label2.set_transform(trans)
345 tick_kw = {k: v for k, v in kwargs.items() if k in ['color', 'zorder']}
346 if 'color' in kwargs:
347 tick_kw['markeredgecolor'] = kwargs['color']
348 self.tick1line.set(**tick_kw)
349 self.tick2line.set(**tick_kw)
350 for k, v in tick_kw.items():
351 setattr(self, '_' + k, v)
352
353 if 'labelrotation' in kwargs:
354 self._set_labelrotation(kwargs.pop('labelrotation'))
355 self.label1.set(rotation=self._labelrotation[1])
356 self.label2.set(rotation=self._labelrotation[1])
357
358 label_kw = {k[5:]: v for k, v in kwargs.items()
359 if k in ['labelsize', 'labelcolor', 'labelfontfamily',
360 'labelrotation_mode']}
361 self.label1.set(**label_kw)
362 self.label2.set(**label_kw)
363
364 grid_kw = {k[5:]: v for k, v in kwargs.items()
365 if k in _gridline_param_names}
366 # If grid_color has an alpha channel and grid_alpha is not explicitly
367 # set, extract the alpha from the color.
368 if 'color' in grid_kw and 'alpha' not in grid_kw:
369 grid_color = grid_kw['color']
370 if mcolors._has_alpha_channel(grid_color):
371 # Convert to rgba to extract alpha
372 rgba = mcolors.to_rgba(grid_color)
373 grid_kw['color'] = rgba[:3] # RGB only
374 grid_kw['alpha'] = rgba[3] # Alpha channel
375 self.gridline.set(**grid_kw)
376
377 def update_position(self, loc):

Callers 2

set_padMethod · 0.95
set_tick_paramsMethod · 0.45

Calls 11

_apply_tickdirMethod · 0.95
_get_text1_transformMethod · 0.95
_get_text2_transformMethod · 0.95
_set_labelrotationMethod · 0.95
set_markersizeMethod · 0.80
set_markeredgewidthMethod · 0.80
set_visibleMethod · 0.45
popMethod · 0.45
set_transformMethod · 0.45
setMethod · 0.45
to_rgbaMethod · 0.45

Tested by

no test coverage detected