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

Skip to content

PDF output does not respect zorder when using imshow #2517

Closed
@mrbump

Description

@mrbump

I already posted this as a question on Stack Overflow.

Minimal example:

import numpy as np
import matplotlib.pyplot as plt

img = np.arange(100).reshape((10,10))
plt.imshow(img, extent = [0.25, 0.75, 0.25, 0.75], zorder = 10)
plt.imshow(img, extent = [0.1, 0.9, 0.1, 0.9], zorder = 1)
plt.plot([0, 1], [0, 1], color = 'black', zorder = 5)
plt.axis([0, 1, 0, 1])

plt.savefig('img.png')

When exporting to PNG, the output is as expected:
img

However, when saving to PDF, the zorder is not respected (the line is plotted over both images):
img pdf

Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions