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

Method _translate_tick_params

lib/matplotlib/axis.py:1092–1160  ·  view source on GitHub ↗

Translate the kwargs supported by `.Axis.set_tick_params` to kwargs supported by `.Tick._apply_params`. In particular, this maps axis specific names like 'top', 'left' to the generic tick1, tick2 logic of the axis. Additionally, there are some other name tra

(cls, kw, reverse=False)

Source from the content-addressed store, hash-verified

1090
1091 @classmethod
1092 def _translate_tick_params(cls, kw, reverse=False):
1093 """
1094 Translate the kwargs supported by `.Axis.set_tick_params` to kwargs
1095 supported by `.Tick._apply_params`.
1096
1097 In particular, this maps axis specific names like 'top', 'left'
1098 to the generic tick1, tick2 logic of the axis. Additionally, there
1099 are some other name translations.
1100
1101 Returns a new dict of translated kwargs.
1102
1103 Note: Use reverse=True to translate from those supported by
1104 `.Tick._apply_params` back to those supported by
1105 `.Axis.set_tick_params`.
1106 """
1107 kw_ = {**kw}
1108
1109 # The following lists may be moved to a more accessible location.
1110 allowed_keys = [
1111 'size', 'width', 'color', 'tickdir', 'pad',
1112 'labelsize', 'labelcolor', 'labelfontfamily', 'zorder', 'gridOn',
1113 'tick1On', 'tick2On', 'label1On', 'label2On',
1114 'length', 'direction', 'left', 'bottom', 'right', 'top',
1115 'labelleft', 'labelbottom', 'labelright', 'labeltop',
1116 'labelrotation', 'labelrotation_mode',
1117 *_gridline_param_names]
1118
1119 keymap = {
1120 # tick_params key -> axis key
1121 'length': 'size',
1122 'direction': 'tickdir',
1123 'rotation': 'labelrotation',
1124 'rotation_mode': 'labelrotation_mode',
1125 'left': 'tick1On',
1126 'bottom': 'tick1On',
1127 'right': 'tick2On',
1128 'top': 'tick2On',
1129 'labelleft': 'label1On',
1130 'labelbottom': 'label1On',
1131 'labelright': 'label2On',
1132 'labeltop': 'label2On',
1133 }
1134 if reverse:
1135 kwtrans = {}
1136 is_x_axis = cls.axis_name == 'x'
1137 y_axis_keys = ['left', 'right', 'labelleft', 'labelright']
1138 for oldkey, newkey in keymap.items():
1139 if newkey in kw_:
1140 if is_x_axis and oldkey in y_axis_keys:
1141 continue
1142 else:
1143 kwtrans[oldkey] = kw_.pop(newkey)
1144 else:
1145 kwtrans = {
1146 newkey: kw_.pop(oldkey)
1147 for oldkey, newkey in keymap.items() if oldkey in kw_
1148 }
1149 if 'colors' in kw_:

Callers 4

set_tick_paramsMethod · 0.95
get_tick_paramsMethod · 0.95

Calls 2

popMethod · 0.45
updateMethod · 0.45

Tested by 2