Skip to content

inverse transform break chaining #10741

Open
@ImportanceOfBeingErnest

Description

@ImportanceOfBeingErnest

Bug report

Bug summary

Transform chaining seems to not be possible in some cases. As an example

tr = ax.transAxes - ax.transData + ax.transData

gives a different result than

tr = ax.transAxes 

although those are linear transformations, which can easily be inverted, so one would expect

A + B^-1 + B == A

The following example shows that this is not the case.

Code for reproduction

The code should create a red and a green line from [0,0] to [1,1] in axes cooridinates. Yet the red line is somehow fixed to its initial prosition and forgets about its transform.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

# apply transform A + B^-1 + B 
# this should equal A
tr = ax.transAxes - ax.transData
trinv = ax.transData
line = plt.Line2D([0,1],[0,1],transform=tr+trinv, color="crimson")
ax.add_line(line)

# apply transform A
line2 = plt.Line2D([0,1],[0,1],transform=ax.transAxes, color="limegreen")
ax.add_line(line2)

ax.set_ylim(.1,1.1)

plt.show()

Actual outcome

image

Expected outcome

A plot with red and green line overlapping.

Now it may well be that I'm completely misunderstanding the transform chaining in which case it would probably be good to update the documentation.

Matplotlib version

  • Operating system: Windows 8.1
  • Matplotlib version: 2.2
  • Matplotlib backend: Qt4Agg as well as TkAgg
  • Python version: 2.7.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesNew featurekeepItems to be ignored by the “Stale” Github Actiontopic: transforms and scales

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions