Skip to content

[Bug]: diagonal lines in pcolormesh with Gouraud shading and transparency #27016

Closed

Description

@limwz01

Bug summary

Diagonal and box lines are produced by pcolormesh using a cmap with transparency.

Code for reproduction

import matplotlib.colors as m_colors
import matplotlib.pyplot as plt
import numpy as np
plt.pcolormesh(np.array([[0, 1, 2], [0, 1, 2]]),
               np.array([[0, 0, 0], [1, 1, 1]]),
               np.array([[0, 1, 2], [0, 1, 2]]),
               cmap=m_colors.LinearSegmentedColormap.from_list(
                   "", [(0, 0, 0, 0), (0, 0, 0, 1)]),
               shading="gouraud")
plt.plot()

Actual outcome

Figure_1

Expected outcome

No diagonal or box lines should appear.

Additional information

No response

Operating system

No response

Matplotlib Version

3.6.2

Matplotlib Backend

QtAgg

Python version

No response

Jupyter version

No response

Installation

None

Activity

  1. AgilentGCMS commented on Nov 28, 2023

    @AgilentGCMS

    Just wondering if there's any activity on this one. I routinely plot data on a map using imshow in cartopy, and would like to use a transparency-aware colormap to show a map background over regions of "uninteresting" data. This is pretty standard in earth science visualization, and perhaps in other fields too. However, this bug prevents me from doing that.

  2. jklymak commented on Nov 28, 2023

    @jklymak
    Member

    Changing the title, as this is only an issue with Gouraud shading...

  3. changed the title [-][Bug]: diagonal and box lines appearing in pcolormesh due to transparency[/-] [+][Bug]: diagonal lines in pcolormesh with Gouraud shading and transparency[/+] on Nov 28, 2023
  4. AgilentGCMS commented on Nov 29, 2023

    @AgilentGCMS

    Yes, I can confirm that this is only a problem for gouraud shading. Unfortunately, other shading options don't work for me unless there's an option to reduce edge width to zero (I tried with edgecolors=None, doesn't do what I want), so I'm stuck with gouraud.

  5. jklymak commented on Nov 29, 2023

    @jklymak
    Member

    edgecolors='none' should work fine, which is also the default, so maybe open a new issue if that doesn't work for you with a reproducible example using only Matplotlib.

  6. AgilentGCMS commented on Nov 29, 2023

    @AgilentGCMS

    Indeed, edgecolors='none' works fine for plots with just matplotlib on a flat canvas. The issue is when using pcolormesh in cartopy, edgecolors='none' and shading='flat' still draws visible edges. Or perhaps the edges are only visible on non-rectangular projections. I'll open a cartopy ticket for that.

  7. AgilentGCMS commented on Nov 29, 2023

    @AgilentGCMS

    FYI, opened (this issue)[https://github.com/SciTools/cartopy/issues/2295] with cartopy.

  8. added this to the v3.12.0 milestone on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions