Skip to content

Commit

Permalink
Support string-type parametric coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Jul 13, 2021
1 parent e26402b commit 02fbda4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion proplot/axes/base.py
Expand Up @@ -1360,7 +1360,11 @@ def parametric(
*args : (y,), (x, y), or (x, y, c)
The coordinates. If `x` is not provided, it is inferred from `y`.
The parametric coordinate can be indicated as a third positional
argument or with the `c` or `values` keywords.
argument or with the `c`, `values`, or `labels` keywords. The
parametric coordinate can be numeric or an array of string labels.
c, values, labels : array-like, optional
The parametric coordinates passed as a keyword argument. They
can also be passed as a third positional argument.
%(axes.cmap_norm)s
interp : int, optional
If greater than ``0``, we interpolate to additional points
Expand Down
5 changes: 4 additions & 1 deletion proplot/axes/plot.py
Expand Up @@ -671,6 +671,7 @@ def _parse_string_coords(*args, which='x', **kwargs):
# correspond to indices while the latter can mysteriously truncate labels.
res = []
for arg in args:
arg = _to_arraylike(arg)
if _is_string(arg) and arg.ndim > 1:
raise ValueError('Non-1D string coordinate input is unsupported.')
if not _is_string(arg):
Expand Down Expand Up @@ -749,7 +750,9 @@ def _auto_format_1d(
if not nocycle:
kwargs['labels'] = _to_ndarray(labels)
elif parametric:
kwargs['values'] = _to_ndarray(labels)
values, colorbar_kw = _parse_string_coords(labels, which='')
kwargs['values'] = _to_ndarray(values)
kwargs.setdefault('colorbar_kw', {}).update(colorbar_kw)

# The basic x and y settings
if not projection:
Expand Down

0 comments on commit 02fbda4

Please sign in to comment.