Skip to content

RuntimeError: adjustable='datalim' is not allowed when both axes are shared. #11416

@nbud

Description

@nbud

Bug report

Bug summary

Matplotlib 2.2.2 fails to plot the figure described below. The code works with Matplotlib 2.0.2.

The issue seems to be the combination of sharex=True, sharey=True and axis('equal').

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

nrows = 3
ncols = 2
fig, axes = plt.subplots(ncols=ncols, nrows=nrows, sharex=True, sharey=True)

n = 20
np.random.seed(1234)
data = np.random.uniform(size=(nrows, ncols, n, n))

for i in range(nrows):
    for j in range(ncols):
        ax = axes[i, j]
        ax.imshow(data[i, j])
        ax.axis("equal")

plt.show()

Actual outcome

With Matplotlib 2.2.2, the figure is not drawn and the following exception is raised:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 519, in _draw_idle
    self.draw()
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 433, in draw
    self.figure.draw(self.renderer)
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1475, in draw
    renderer, self, artists, self.suppressComposite)
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2546, in draw
    self.apply_aspect()
  File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 1631, in apply_aspect
    raise RuntimeError("adjustable='datalim' is not allowed when both"
RuntimeError: adjustable='datalim' is not allowed when both axes are shared.

Expected outcome

Drawn figure, no error, as with Matplotlib 2.0.2

Matplotlib version

  • Operating system: Windows 7 64 bits
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6
  • Jupyter version (if applicable):
  • Other libraries: Anaconda 5.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy