Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when many marker/colors are needed #37

Open
malmans2 opened this issue Apr 5, 2023 · 0 comments · May be fixed by #38
Open

Error when many marker/colors are needed #37

malmans2 opened this issue Apr 5, 2023 · 0 comments · May be fixed by #38

Comments

@malmans2
Copy link

malmans2 commented Apr 5, 2023

Hi there,

I think I found an issue when many markers need to be displayed (I'm not an heavy user of this library, so maybe I'm just missing something...).

Here is a MRE:

import skill_metrics
import numpy as np

size = 10
skill_metrics.taylor_diagram(
    np.random.randn(size),
    np.random.randn(size),
    np.random.uniform(size=size),
    alpha=0.0,
    axismax=4,
    colCOR="k",
    colOBS="k",
    colRMS="m",
    colSTD="b",
    markerLabel=[str(i) for i in range(size)],
    markerLegend="on",
    markerSize=10,
    markerobs="o",
    styleCOR="--",
    styleOBS="--",
    styleRMS=":",
    styleSTD="-.",
    tickRMS=np.linspace(0, 4, 5),
    tickSTD=np.linspace(0, 4, 5),
    titleCOR="on",
    titleOBS="0",
    titleRMS="on",
    titleRMSDangle=40.0,
    titleSTD="on",
    widthCOR=0.5,
    widthOBS=2,
    widthRMS=2,
    widthSTD=1.0,
)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 5
      2 import numpy as np
      4 size = 10
----> 5 skill_metrics.taylor_diagram(
      6     np.random.randn(size),
      7     np.random.randn(size),
      8     np.random.uniform(size=size),
      9     alpha=0.0,
     10     axismax=4,
     11     colCOR="k",
     12     colOBS="k",
     13     colRMS="m",
     14     colSTD="b",
     15     markerLabel=[str(i) for i in range(size)],
     16     markerLegend="on",
     17     markerSize=10,
     18     markerobs="o",
     19     styleCOR="--",
     20     styleOBS="--",
     21     styleRMS=":",
     22     styleSTD="-.",
     23     tickRMS=np.linspace(0, 4, 5),
     24     tickSTD=np.linspace(0, 4, 5),
     25     titleCOR="on",
     26     titleOBS="0",
     27     titleRMS="on",
     28     titleRMSDangle=40.0,
     29     titleSTD="on",
     30     widthCOR=0.5,
     31     widthOBS=2,
     32     widthRMS=2,
     33     widthSTD=1.0,
     34 )

File ~/mambaforge/envs/eqc/lib/python3.10/site-packages/skill_metrics/taylor_diagram.py:385, in taylor_diagram(*args, **kwargs)
    383 lowcase = options['markerdisplayed'].lower()
    384 if lowcase == 'marker':
--> 385     plot_pattern_diagram_markers(ax, X, Y, options)
    386 elif lowcase == 'colorbar':
    387     nZdata = len(options['cmapzdata'])

File ~/mambaforge/envs/eqc/lib/python3.10/site-packages/skill_metrics/plot_pattern_diagram_markers.py:90, in plot_pattern_diagram_markers(ax, X, Y, option)
     88 for i, xval in enumerate(X):
     89     if abs(X[i]) <= limit and abs(Y[i]) <= limit:
---> 90         h = ax.plot(X[i],Y[i],marker[i], markersize = markerSize,
     91              markerfacecolor = markercolor[i],
     92              markeredgecolor = markercolor[i][0:3] + (1.0,),
     93              markeredgewidth = 2)
     94         hp += tuple(h)
     95         labelcolor.append(option['markerlabelcolor'])

File ~/mambaforge/envs/eqc/lib/python3.10/site-packages/matplotlib/axes/_axes.py:1688, in Axes.plot(self, scalex, scaley, data, *args, **kwargs)
   1445 """
   1446 Plot y versus x as lines and/or markers.
   1447
   (...)
   1685 (``'green'``) or hex strings (``'#008000'``).
   1686 """
   1687 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
-> 1688 lines = [*self._get_lines(*args, data=data, **kwargs)]
   1689 for line in lines:
   1690     self.add_line(line)

File ~/mambaforge/envs/eqc/lib/python3.10/site-packages/matplotlib/axes/_base.py:311, in _process_plot_var_args.__call__(self, data, *args, **kwargs)
    309     this += args[0],
    310     args = args[1:]
--> 311 yield from self._plot_args(
    312     this, kwargs, ambiguous_fmt_datakey=ambiguous_fmt_datakey)

File ~/mambaforge/envs/eqc/lib/python3.10/site-packages/matplotlib/axes/_base.py:454, in _process_plot_var_args._plot_args(self, tup, kwargs, return_kwargs, ambiguous_fmt_datakey)
    451 if len(tup) > 1 and isinstance(tup[-1], str):
    452     # xy is tup with fmt stripped (could still be (y,) only)
    453     *xy, fmt = tup
--> 454     linestyle, marker, color = _process_plot_format(
    455         fmt, ambiguous_fmt_datakey=ambiguous_fmt_datakey)
    456 elif len(tup) == 3:
    457     raise ValueError('third arg must be a format string')

File ~/mambaforge/envs/eqc/lib/python3.10/site-packages/matplotlib/axes/_base.py:190, in _process_plot_format(fmt, ambiguous_fmt_datakey)
    188 elif c in mcolors.get_named_colors_mapping():
    189     if color is not None:
--> 190         raise ValueError(errfmt.format(fmt, "two color symbols"))
    191     color = c
    192     i += 1

ValueError: 'pgray' is not a valid format string (two color symbols)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant