Skip to content

RGBA values produce different result for imshow and for markers #7201

Closed

Description

@astrofrog

In the following example, I produce 9 colors ranging from completely transparent red to completely opaque red. In the case of imshow, the lighter colors actually end up being closer to gray, whereas for the scatter markers, the colors look as one would expect. What could be causing this?

import numpy as np
import matplotlib.pyplot as plt

data = np.arange(9, dtype=float).reshape((3, 3)) / 8.

color = np.array([1, 0, 0, 1], dtype=float)

array = color * np.ones(data.shape + (4,))
array[:, :, 3] *= data

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.imshow(array, vmin=0, vmax=1, interpolation='nearest')
for i in range(3):
    for j in range(3):
        ax.scatter(i, j, s=500, facecolor='white', edgecolor='white', alpha=1.0)
        ax.scatter(i, j, s=400, facecolor=array[j, i], edgecolor='white')
fig.savefig('colors.png')

colors

Activity

  1. QuLogic commented on Sep 29, 2016

    @QuLogic
    Member

    This works in 2.x as you'd expect:
    colors

    Not sure when it was fixed.

  2. QuLogic commented on Sep 29, 2016

    @QuLogic
    Member

    Maybe a dupe of #5949, but it's fixed by #5718.

  3. added this to the milestone on Sep 29, 2016
  4. QuLogic commented on Sep 30, 2016

    @QuLogic
    Member

    Sorry, that first reference should be to #3343.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions