|
90 | 90 | } |
91 | 91 |
|
92 | 92 |
|
| 93 | +# Unit docstrings |
| 94 | +# NOTE: Try to fit this into a single line. Cannot break up with newline as that will |
| 95 | +# mess up docstring indentation since this is placed in indented param lines. |
| 96 | +_units_docstring = 'If float, units are {units}. If string, interpreted by `~proplot.utils.units`.' # noqa: E501 |
| 97 | +docstring._snippet_manager['units.pt'] = _units_docstring.format(units='points') |
| 98 | +docstring._snippet_manager['units.in'] = _units_docstring.format(units='inches') |
| 99 | +docstring._snippet_manager['units.em'] = _units_docstring.format(units='em-widths') |
| 100 | + |
| 101 | + |
93 | 102 | # Style docstrings |
94 | 103 | # NOTE: These are needed in a few different places |
95 | 104 | _line_docstring = """ |
96 | | -lw, linewidth, linewidths : float, optional |
| 105 | +lw, linewidth, linewidths : unit-spec, optional |
97 | 106 | The width of the line(s). Default is :rc:`lines.linewidth`. |
| 107 | + %(units.pt)s |
98 | 108 | ls, linestyle, linestyles : str, optional |
99 | 109 | The style of the line(s). Default is :rc:`lines.linestyle`. |
100 | 110 | c, color, colors : color-spec, optional |
|
103 | 113 | The opacity of the line(s). |
104 | 114 | """ |
105 | 115 | _patch_docstring = """ |
106 | | -lw, linewidth, linewidths : float, optional |
| 116 | +lw, linewidth, linewidths : unit-spec, optional |
107 | 117 | The edge width of the patch(es). Default is :rc:`patch.linewidth`. |
| 118 | + %(units.pt)s |
108 | 119 | ls, linestyle, linestyles : str, optional |
109 | 120 | The edge style of the patch(es). Default is ``'-'``. |
110 | 121 | ec, edgecolor, edgecolors : color-spec, optional |
|
115 | 126 | The opacity of the patch(es). |
116 | 127 | """ |
117 | 128 | _pcolor_collection_docstring = """ |
118 | | -lw, linewidth, linewidths : float, optional |
| 129 | +lw, linewidth, linewidths : unit-spec, optional |
119 | 130 | The width of lines between grid boxes. |
| 131 | + %(units.pt)s |
120 | 132 | ls, linestyle, linestyles : str, optional |
121 | 133 | The style of lines between grid boxes. |
122 | 134 | ec, edgecolor, edgecolors : color-spec, optional |
|
125 | 137 | The opacity of the grid boxes. |
126 | 138 | """ |
127 | 139 | _contour_collection_docstring = """ |
128 | | -lw, linewidth, linewidths : float, optional |
| 140 | +lw, linewidth, linewidths : unit-spec, optional |
129 | 141 | The width of the contour lines. For `contourf` plots, |
130 | 142 | lines are added between the filled contours. |
| 143 | + %(units.pt)s |
131 | 144 | ls, linestyle, linestyles : str, optional |
132 | 145 | The style of the contour lines. For `contourf` plots, |
133 | 146 | lines are added between the filled contours. |
@@ -306,9 +319,13 @@ def _pop_props(input, *categories, prefix=None, ignore=None, skip=None): |
306 | 319 | if any(string in key for string in ignore): |
307 | 320 | warnings._warn_proplot(f'Ignoring property {key}={prop!r}.') |
308 | 321 | continue |
309 | | - if key in ('fontsize',): |
310 | | - from ..config import _fontsize_to_pt |
311 | | - prop = _fontsize_to_pt(prop) |
| 322 | + if isinstance(prop, str): |
| 323 | + if key in ('fontsize',): |
| 324 | + from ..config import _fontsize_to_pt |
| 325 | + prop = _fontsize_to_pt(prop) |
| 326 | + if key in ('linewidth', 'linewidths', 'markersize'): |
| 327 | + from ..utils import units |
| 328 | + prop = units(prop, 'pt') |
312 | 329 | output[key] = prop |
313 | 330 | return output |
314 | 331 |
|
|
0 commit comments