(I originally posted this as a question on Stackoverflow)
I have a matplotlib patch that I want to add to two different axis objects. Calling ax1.add_patch(my_patch) the first time leads to the correct result, but when I call ax2.add_patch(my_patch), the patch is offset horizontally. Calling add_patch again after that does not change the offset.
This only seems to happen when using %matplotlib inline. Generating the figures in separate windows does not lead to the offset.
Minimal example:
import numpy as np
from matplotlib.patches import Circle
import matplotlib.pyplot as plt
%matplotlib inline
grid = np.ones([10,10])
circle = Circle((5,5), 2)
fig1, ax1 = plt.subplots()
ax1.imshow(grid, interpolation='None')
ax1.add_patch(circle)
fig2, ax2 = plt.subplots()
ax2.imshow(grid, interpolation='None')
ax2.add_patch(circle)

System information:
'commit_hash': u'cbccb68',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/usr/local/lib/python2.7/dist-packages/IPython',
'ipython_version': '3.1.0',
'os_name': 'posix',
'platform': 'Linux-3.13.0-24-generic-x86_64-with-LinuxMint-17-qiana',
'sys_executable': '/usr/bin/python',
'sys_platform': 'linux2',
'sys_version': '2.7.6 (default, Mar 22 2014, 22:59:56) \n[GCC 4.8.2]'
'matplotlib.__version__': '1.4.3'
(I originally posted this as a question on Stackoverflow)
I have a matplotlib
patchthat I want to add to two different axis objects. Callingax1.add_patch(my_patch)the first time leads to the correct result, but when I callax2.add_patch(my_patch), the patch is offset horizontally. Callingadd_patchagain after that does not change the offset.This only seems to happen when using
%matplotlib inline. Generating the figures in separate windows does not lead to the offset.Minimal example:
System information:
'matplotlib.__version__': '1.4.3'