Skip to content

Adding a matplotlib patch to inline axis twice in a notebook causes offset #8507

Description

@jdugge

(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)

image


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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions