`savefig` messes up coordinate transformation of `annotate` · Issue #4375 · matplotlib/matplotlib · GitHub
Skip to content

savefig messes up coordinate transformation of annotate #4375

Description

@PiQuer

I want to annotate a data point with an inset axis (matplotlib-1.4.3, Linux):

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.axes_grid1.inset_locator import inset_axes

x=np.linspace(0,10,200)
y=np.exp(-x)*np.sin(x)

fig,ax = plt.subplots(figsize=(3.39,3))

ax.plot(x,y)

axins=inset_axes(ax, width=0.6, height=0.6, bbox_to_anchor=(6, 0.2),bbox_transform=ax.transData)
axins.axes.get_xaxis().set_visible(False)
axins.axes.get_yaxis().set_visible(False)
ax.annotate("",xy=(x[150],y[150]), xycoords=ax.transData,
        xytext=(1, 0), textcoords=axins.transAxes,
        arrowprops=dict(arrowstyle="->"))

fig.savefig('example.pdf')
plt.show()

This is the correct plot shown on screen:
shown
This is what savefig produces:
example

Apparently savefig changes the coordinates (1,0) from the inset axes to the parent axes for some reason.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions