X Tutup
Skip to content

Using gray shade from string ignores alpha parameters #6513

@zblz

Description

@zblz

Using matplotlib master and a color defined by a string indicating a gray shade, the alpha parameter gets ignored in calls to, e.g. plt.plot. Example:

intercepts=np.random.randn(100)

ms=np.random.randn(100)
x=np.linspace(-5,5,100)
for m,i in zip(ms,intercepts):
    plt.plot(m*x+i, c='0.1', alpha=0.2)

results in:
string

whereas the expected result can be obtained by converting the string to a tuple:

for m,i in zip(ms,intercepts):
    plt.plot(m*x+i, c=(0.1, 0.1, 0.1, 1.0), alpha=0.2)

tuple

Looking at the code, it seems that all colors are passed through colors.to_rgba, and in my setup it correctly converts the string to the tuple, so it seems the problem is elsewhere.

>>> mpl.colors.to_rgba('0.1')
(0.1, 0.1, 0.1, 1.0)

This used to work in previous v2.x branch commits (cannot really pinpoint where it failed first time) and in v1.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup