Skip to content

'color' LineCollection prop overrides 'colors' kwarg in ax.eventplot() #4297

@alimuldal

Description

@alimuldal

Just came across a minor annoyance in the ax.eventplot() API. Currently if you pass color= this overrides the colors= kwarg, and instead of setting a single color for each row of event markers, it has the effect of setting a repeating color sequence for the markers within every row.

Hopefully this example illustrates what I'm talking about:

import numpy as np
from matplotlib import pyplot as plt

np.random.seed(0)
data1 = np.random.random([20])
data2 = np.random.random([10])
data = [data1, data2]

fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)

# expected
ax1.eventplot(data, colors=['r', 'b'])

# 'color' overrides 'colors'
ax2.eventplot(data, colors=['r', 'b'], color=['c', 'm'])

plt.show()

eventplot 'color' overrride example

It took me an embarrassingly long time to figure out that I needed to pass colors rather than color in order to set the color for each row.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions