|
99 | 99 | which sides of the map. Use the keyword `labels` to set both at once. The |
100 | 100 | argument must conform to one of the following options: |
101 | 101 |
|
102 | | - 1. A boolean. ``True`` indicates the left side for latitudes, bottom |
103 | | - side for longitudes, and ``False`` disables all labels. |
104 | | - 2. A string or sequence of strings indicating the side names, e.g. |
105 | | - ``'left'`` for latitudes or ``('top', 'bottom')`` for longitudes. |
106 | | - 3. A string indicating the side names with single characters, e.g. |
107 | | - ``'lr'`` for latitudes or ``'bt'`` for longitudes. |
108 | | - 4. A boolean 2-tuple indicating whether to draw labels on the |
109 | | - ``(left, right)`` sides for latitudes, or ``(bottom, top)`` |
110 | | - sides for longitudes. |
111 | | - 5. A boolean 4-tuple indicating whether to draw labels on the |
112 | | - ``(left, right, bottom, top)`` sides, as with the basemap |
113 | | - `~mpl_toolkits.basemap.Basemap.drawmeridians` and |
114 | | - `~mpl_toolkits.basemap.Basemap.drawparallels` `labels` keyword. |
| 102 | + * A boolean. ``True`` indicates the bottom side for longitudes and |
| 103 | + the left side for latitudes, and ``False`` disables all labels. |
| 104 | + * A string or sequence of strings indicating the side names, e.g. |
| 105 | + ``'top'`` for longitudes or ``('left', 'right')`` for latitudes. |
| 106 | + * A string indicating the side names with single characters, e.g. |
| 107 | + ``'bt'`` for longitudes or ``'lr'`` for latitudes. |
| 108 | + * A string matching ``'neither'`` (no labels), ``'both'`` (equivalent |
| 109 | + to ``'bt'`` for longitudes and ``'lr'`` for latitudes), or ``'all'`` |
| 110 | + (equivalent to ``'lrbt'``, i.e. all sides). |
| 111 | + * A boolean 2-tuple indicating whether to draw labels |
| 112 | + on the ``(bottom, top)`` sides for longitudes, |
| 113 | + and the ``(left, right)`` sides for latitudes. |
| 114 | + * A boolean 4-tuple indicating whether to draw labels on the |
| 115 | + ``(left, right, bottom, top)`` sides, as with the basemap |
| 116 | + `~mpl_toolkits.basemap.Basemap.drawmeridians` and |
| 117 | + `~mpl_toolkits.basemap.Basemap.drawparallels` `labels` keyword. |
115 | 118 |
|
116 | 119 | loninline, latinline, inlinelabels : bool, default: :rc:`grid.inlinelabels` |
117 | 120 | *For cartopy axes only.* |
@@ -502,12 +505,18 @@ def _to_label_array(arg, lon=True): |
502 | 505 | array = [False] * 5 |
503 | 506 | opts = ('left', 'right', 'bottom', 'top', 'geo') |
504 | 507 | for string in strings: |
505 | | - if string in opts: |
| 508 | + if string == 'all': |
| 509 | + string = 'lrbt' |
| 510 | + elif string == 'both': |
| 511 | + string = 'bt' if lon else 'lr' |
| 512 | + elif string == 'neither': |
| 513 | + string = '' |
| 514 | + elif string in opts: |
506 | 515 | string = string[0] |
507 | | - elif set(string) - set('lrbtg'): |
| 516 | + if set(string) - set('lrbtg'): |
508 | 517 | raise ValueError( |
509 | 518 | f'Invalid {which}label string {string!r}. Must be one of ' |
510 | | - + ', '.join(map(repr, opts)) |
| 519 | + + ', '.join(map(repr, (*opts, 'neither', 'both', 'all'))) |
511 | 520 | + " or a string of single-letter characters like 'lr'." |
512 | 521 | ) |
513 | 522 | for char in string: |
|
0 commit comments