Skip to content

eventplot: allow a list of alpha channels as in the case with colors #19376

Closed
@dizcza

Description

@dizcza

I'm not sure if it's a bug or a feature. It's both.

>>> plt.eventplot([[0, 1, 2], [0.5, 2.3]], color=['r', 'g'])

works while

>>> plt.eventplot([[0, 1, 2], [0.5, 2.3]], alpha=[0.5, 0.2])

throws an error

Traceback (most recent call last):
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3319, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-fab7f3737c6e>", line 1, in <module>
    plt.eventplot([[0, 1, 2], [0.5, 2.3]], alpha=[0.5, 0.2])
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2622, in eventplot
    **({"data": data} if data is not None else {}), **kwargs)
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/matplotlib/__init__.py", line 1447, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 1480, in eventplot
    coll.update(kwargs)
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/matplotlib/artist.py", line 998, in update
    ret.append(func(v))
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/matplotlib/collections.py", line 834, in set_alpha
    super().set_alpha(alpha)
  File "/home/ulianych/anaconda3/envs/viziphant/lib/python3.7/site-packages/matplotlib/artist.py", line 930, in set_alpha
    raise TypeError('alpha must be a float or None')
TypeError: alpha must be a float or None

matplotlib v3.3.3
Python 3.7.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions