MCPcopy Create free account
hub / github.com/erwanp/publib / fix_style

Function fix_style

publib/publib.py:157–201  ·  view source on GitHub ↗

Add an extra formatting layer to an axe, that couldn't be changed directly in matplotlib.rcParams or with styles. Apply this function to every axe you created. Parameters ---------- ax: a matplotlib axe. If None, the last axe generated is used style: st

(style='basic', ax=None, **kwargs)

Source from the content-addressed store, hash-verified

155
156
157def fix_style(style='basic', ax=None, **kwargs):
158 '''
159 Add an extra formatting layer to an axe, that couldn't be changed directly
160 in matplotlib.rcParams or with styles. Apply this function to every axe
161 you created.
162
163 Parameters
164 ----------
165 ax: a matplotlib axe.
166 If None, the last axe generated is used
167 style: string or list of string
168 ['basic', 'article', 'poster', 'B&W','talk','origin']
169 one of the styles previously defined. It should match the style you
170 chose in set_style but nothing forces you to.
171 kwargs: dict
172 edit any of the style_params keys. ex:
173
174 >>> tight_layout=False
175
176 Examples
177 --------
178 plb.set_style('poster')
179 plt.plot(a,np.cos(a))
180 plb.fix_style('poster',**{'draggable_legend':False})
181
182 See Also
183 --------
184
185 :func:`~publib.publib.set_style`
186
187 '''
188
189 style = _read_style(style)
190
191 # Apply all styles
192 for s in style:
193
194 if not s in style_params.keys():
195 avail = [f.replace('.mplstyle', '') for f in os.listdir(
196 _get_lib()) if f.endswith('.mplstyle')]
197 raise ValueError('{0} is not a valid style. '.format(s) +
198 'Please pick a style from the list available in ' +
199 '{0}: {1}'.format(_get_lib(), avail))
200
201 _fix_style(style, ax, **kwargs)
202
203
204def _fix_style(styles, ax=None, **kwargs):

Callers 1

test_routinesFunction · 0.90

Calls 3

_read_styleFunction · 0.85
_get_libFunction · 0.85
_fix_styleFunction · 0.85

Tested by 1

test_routinesFunction · 0.72