Thanks to visit codestin.com
Credit goes to github.com

Skip to content

NonUniformImage wrong image when using large values for axis #15039

@funkygoby

Description

@funkygoby

When using matplotlib.image.NonUniformImage with large values on axis (~10e+7), the plot breaks.

I am plotting a random matrix and simply offsetting the axis by with a large value:

Normal behaviour
ok

Strange behaviour
not_ok

The code

import numpy
import matplotlib.pyplot as plt
from matplotlib.image import NonUniformImage

offset = 9.*10**6 # XXX change this XXX
nx = 60
ny = 100
x = numpy.arange(offset, offset+nx)
y = numpy.arange(offset, offset+ny)
z = numpy.random.rand(ny, nx)

ax = plt.subplot(111)
im = NonUniformImage(ax, extent=(offset, offset+nx, offset, offset+ny))
im.set_data(x, y, z)
ax.images.append(im)
ax.set_xlim(offset, offset+nx)
ax.set_ylim(offset, offset+ny)

plt.show()

By changing the offset variable, one can achieve different results: 1. is ok; 9. is broken.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions