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)
| 155 | |
| 156 | |
| 157 | def 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 | |
| 204 | def _fix_style(styles, ax=None, **kwargs): |