Description
Bug report
Bug summary
When plotting with imshow
using the PDF (or SVG) backend the right and top edges of the extent are not correct. The left and bottom edges seem to be correct.
The deviation is small but noticeable (I used a smaller figure size to make it more visible -- it seems not to scale with figure size). It also appears to be unaffected by the interpolation mode. I noticed while returning to an old set of scripts -- I think this wasn't an issue for MPL pre-2.0 but unfortunately I'm unable to be more specific than that.
A minimal code example is given below (I've tested it with a blank matplotlibrc as well and the issue persists).
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
fig.set_size_inches([2,2])
ax = fig.add_subplot(111)
x0, x1 = 0.0, 1.0
ax.set_xlim(x0-0.1,x1+0.1)
ax.set_ylim(x0-0.1,x1+0.1)
ax.plot([x0,x0],[x0,x1],color='r',lw=0.1)
ax.plot([x1,x1],[x0,x1],color='r',lw=0.1)
ax.plot([x0,x1],[x0,x0],color='r',lw=0.1)
ax.plot([x0,x1],[x1,x1],color='r',lw=0.1)
ax.imshow(np.zeros((16,16))+0.5,
cmap='Blues',
origin='lower left',
extent=(x0,x1,x0,x1),
interpolation='none',
vmin=0,vmax=1)
fig.savefig("minimal.pdf")
fig.savefig("minimal.png",dpi=600)
Actual outcome
The red outlines (set to match the extent) are not at the edge of the blue square. See the PDF examplee and the zoomed version (attached below).
Expected outcome
The red outlines (set to match the extent) should be at the edge of the blue square. See the PNG example and the zoomed version (attached below).
Matplotlib version
- Operating System: Linux 4.12.3-1-ARCH
- Matplotlib Version: 2.0.2 (Both packaged from Arch and latest version compiled myself)
- Python Version: 2.7.13 and 3.6.2