Check each axes has expected tick properties Parameters ---------- axes : matplotlib Axes object, or its list-like xlabelsize : number expected xticks font size xrot : number expected xticks rotation ylabelsize : number expected yticks font size
(axes, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None)
| 216 | |
| 217 | |
| 218 | def _check_ticks_props(axes, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None): |
| 219 | """ |
| 220 | Check each axes has expected tick properties |
| 221 | |
| 222 | Parameters |
| 223 | ---------- |
| 224 | axes : matplotlib Axes object, or its list-like |
| 225 | xlabelsize : number |
| 226 | expected xticks font size |
| 227 | xrot : number |
| 228 | expected xticks rotation |
| 229 | ylabelsize : number |
| 230 | expected yticks font size |
| 231 | yrot : number |
| 232 | expected yticks rotation |
| 233 | """ |
| 234 | from matplotlib.ticker import NullFormatter |
| 235 | |
| 236 | axes = _flatten_visible(axes) |
| 237 | for ax in axes: |
| 238 | if xlabelsize is not None or xrot is not None: |
| 239 | if isinstance(ax.xaxis.get_minor_formatter(), NullFormatter): |
| 240 | # If minor ticks has NullFormatter, rot / fontsize are not |
| 241 | # retained |
| 242 | labels = ax.get_xticklabels() |
| 243 | else: |
| 244 | labels = ax.get_xticklabels() + ax.get_xticklabels(minor=True) |
| 245 | |
| 246 | for label in labels: |
| 247 | if xlabelsize is not None: |
| 248 | tm.assert_almost_equal(label.get_fontsize(), xlabelsize) |
| 249 | if xrot is not None: |
| 250 | tm.assert_almost_equal(label.get_rotation(), xrot) |
| 251 | |
| 252 | if ylabelsize is not None or yrot is not None: |
| 253 | if isinstance(ax.yaxis.get_minor_formatter(), NullFormatter): |
| 254 | labels = ax.get_yticklabels() |
| 255 | else: |
| 256 | labels = ax.get_yticklabels() + ax.get_yticklabels(minor=True) |
| 257 | |
| 258 | for label in labels: |
| 259 | if ylabelsize is not None: |
| 260 | tm.assert_almost_equal(label.get_fontsize(), ylabelsize) |
| 261 | if yrot is not None: |
| 262 | tm.assert_almost_equal(label.get_rotation(), yrot) |
| 263 | |
| 264 | |
| 265 | def _check_ax_scales(axes, xaxis="linear", yaxis="linear"): |