<p dir="auto">When I create a figure using bbox images, everything looks fine, but when I save the figure, the images move.  Here is an example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import numpy as np
from matplotlib.image import BboxImage
from matplotlib.transforms import Bbox, TransformedBbox

#Generate the image
im = np.random.rand(10, 10) * 255.0

#Set up figure
fig = plt.figure()
ax = fig.add_axes([0.1,0.1,0.8,0.8])
ax.set_xlim(-2,24)
ax.set_ylim(0,10)

#Create image that transforms automatically
bbox1 = Bbox.from_extents([0,0,10,10])
trans_bbox1 = TransformedBbox(bbox1, ax.transData)
bbox_image1 = BboxImage(trans_bbox1)
bbox_image1.set_data(im)
ax.add_image(bbox_image1)

#Create image that does not transform
bbox2 = Bbox.from_extents([12,0,22,10])
trans_bbox2 = bbox2.transformed(ax.transData)
bbox_image2 = BboxImage(trans_bbox2)
bbox_image2.set_data(im)
ax.add_image(bbox_image2)

#Save the result
fig.savefig('png_test.png')
fig.savefig('pdf_test.pdf')"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt
import numpy as np
from matplotlib.image import BboxImage
from matplotlib.transforms import Bbox, TransformedBbox

#Generate the image
im = np.random.rand(10, 10) * 255.0

#Set up figure
fig = plt.figure()
ax = fig.add_axes([0.1,0.1,0.8,0.8])
ax.set_xlim(-2,24)
ax.set_ylim(0,10)

#Create image that transforms automatically
bbox1 = Bbox.from_extents([0,0,10,10])
trans_bbox1 = TransformedBbox(bbox1, ax.transData)
bbox_image1 = BboxImage(trans_bbox1)
bbox_image1.set_data(im)
ax.add_image(bbox_image1)

#Create image that does not transform
bbox2 = Bbox.from_extents([12,0,22,10])
trans_bbox2 = bbox2.transformed(ax.transData)
bbox_image2 = BboxImage(trans_bbox2)
bbox_image2.set_data(im)
ax.add_image(bbox_image2)

#Save the result
fig.savefig('png_test.png')
fig.savefig('pdf_test.pdf')
</code></pre></div>
<p dir="auto">If I take a screenshot of the figure window, it looks like this<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/4099759/5422678/7c175458-824d-11e4-98c2-077af0a6b101.png"><img src="https://cloud.githubusercontent.com/assets/4099759/5422678/7c175458-824d-11e4-98c2-077af0a6b101.png" alt="screenshot" style="max-width: 100%;"></a><br>
which is what I expect.  However, when I look at the 'png_test.png', the second image that did not use the <code class="notranslate">TransformedBbox</code> moves, as shown below<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/4099759/5422682/b8bedb42-824d-11e4-8d6f-5f61ba3aae3b.png"><img src="https://cloud.githubusercontent.com/assets/4099759/5422682/b8bedb42-824d-11e4-8d6f-5f61ba3aae3b.png" alt="png_test" style="max-width: 100%;"></a><br>
In the pdf, both images move, as shown below<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/4099759/5422689/eceb7010-824d-11e4-8682-9576bab2111b.png"><img src="https://cloud.githubusercontent.com/assets/4099759/5422689/eceb7010-824d-11e4-8682-9576bab2111b.png" alt="pdf_test" style="max-width: 100%;"></a></p>
<p dir="auto">In case it matters, I am using the Qt4Agg interactive backend with the Spyder IDE.  My matplotlib version is 1.4.0.</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">I'm intermittently getting the warning <code class="notranslate">font family ['serif'] not found. Falling back to DejaVu Sans</code> when plotting with <code class="notranslate">rc('text', usetex=True)</code> enabled. If I delete <code class="notranslate">~\.cache\matplotlib</code> the warning stops and the charts are rendered with the correct font. But a day or so later it starts again</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<p dir="auto">Cannot reliably reproduce as intermittent, can reliably fix by deleting <code class="notranslate">~\.cache\matplotlib</code></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system: Ubuntu 18.04</li>
<li>Matplotlib version: 3.0.2</li>
<li>Matplotlib backend: module://ipykernel.pylab.backend_inline</li>
<li>Python version: 3.7.1 x64</li>
<li>Jupyter version (if applicable): 4.4.0</li>
<li>Other libraries:</li>
</ul>


<p dir="auto">installed from pip</p>