Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Should clearing a shared axes reset its scale? #23503

Copy link
Copy link
Open
@anntzer

Description

@anntzer
Issue body actions

Bug summary

Shared axes normally share the same scale, but it is inconsistent whether clear()ing a shared axes resets the scale on that axes, or on the shared axes too.

Code for reproduction

# Create 6 pairs of shared axes,
# set either of them to xscale("log"),
# then do noting or clear() either of them.

from pylab import *

sfs[0].suptitle("set primary")
ax0 = sfs[0].add_subplot(211)
ax1 = sfs[0].add_subplot(212, sharex=ax0)
ax0.set_xscale("log")

sfs[1].suptitle("set secondary")
ax0 = sfs[1].add_subplot(211)
ax1 = sfs[1].add_subplot(212, sharex=ax0)
ax1.set_xscale("log")

sfs[2].suptitle("set primary\nclear secondary")
ax0 = sfs[2].add_subplot(211)
ax1 = sfs[2].add_subplot(212, sharex=ax0)
ax0.set_xscale("log"); ax0.clear()

sfs[3].suptitle("set primary\nclear secondary")
ax0 = sfs[3].add_subplot(211)
ax1 = sfs[3].add_subplot(212, sharex=ax0)
ax0.set_xscale("log"); ax1.clear()

sfs[4].suptitle("set secondary\nclear primary")
ax0 = sfs[4].add_subplot(211)
ax1 = sfs[4].add_subplot(212, sharex=ax0)
ax1.set_xscale("log"); ax0.clear()

sfs[5].suptitle("set secondary\nclear secondary")
ax0 = sfs[5].add_subplot(211)
ax1 = sfs[5].add_subplot(212, sharex=ax0)
ax1.set_xscale("log"); ax1.clear()

for sf in sfs:
    for ax in sf.axes:
        ax.text(.5, .5, ax.get_xscale(), transform=ax.transAxes,
                ha="center", va="center")
        ax.set_yticks([])

show()

Actual outcome

test

Setting the scale on either axes of a pair also sets the scale on the other axes.
Clearing the primary axes changes it, but doesn't affect the secondary axes.
Clearing the secondary axes doesn't affect either the primary or the secondary axes.

Expected outcome

Not sure what the best behavior is, but ending with a pair of shared axes with different scales is probably not good (e.g., because they also share locators and tickers, but linear locators don't play well with log scales as the former don't know anything about avoiding negative values -- this is more or less the root cause of #9970.).

Additional information

No response

Operating system

Arch

Matplotlib Version

3.6.0.dev2729+g446de7bbb6

Matplotlib Backend

mplcairo

Python version

Python 3.10.5

Jupyter version

ENOSUCHLIB

Installation

git checkout

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.