X Tutup
Skip to content

matplotlib pcolormesh seems to slide some data around on the plot #6331

@mnky9800n

Description

@mnky9800n

Note, this question was originally posted by me on stackoverflow

Matplotlib Version = 1.5.1
Installation method = anaconda

I'm plotting data using the matplotlib functions pcolormesh and imshow and when I use pcolormesh it produces artifacts where it seems to slide some of the data around:

pcolormesh

whereas imshow does not:

enter image description here

I was able to produce an example that has the same artifacting

import numpy as np
import pandas as pd

data = pd.DataFrame({'x':np.random.normal(loc=0.5, size=5000)
                     , 'y':np.random.normal(loc=0.5, size=5000)
                     , 'z':np.random.normal(loc=0.5, size=5000)})

data_pivot = data.pivot(index='x', columns='y', values='z')
x = data_pivot.index.values
y = data_pivot.columns.values
z = data_pivot.values
masked_data = np.ma.masked_invalid(z)

which produces the following figures like so:

fig, ax = plt.subplots(1, figsize=(8,8))
ax.pcolormesh(x, y, masked_data)

enter image description here

Where do these artifacts come from? There isn't anything wrong with the data as far as I can tell since the original data and the made up data produce the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup