Open
Description
Bug report
Bug summary
I expect that a matplotlib.text.Text object should disappear when clipped by setting clip_path=some_path
. In practice, the text is still here.
Code for reproduction
import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
plt.figure(figsize=(8,8))
ax = plt.gca()
poly = mpl.patches.Polygon([[1,0], [0,1], [-1,0], [0,-1]],
facecolor="#ddffdd", edgecolor="#00ff00", linewidth=2, alpha=0.5)
ax.add_patch(poly)
# should not be displayed ...
txt_outside = mpl.text.Text(0.75,0.75,"outside :(", clip_on=True, clip_path=poly)
ax.add_artist(txt_outside)
# should be (and is) displayed
txt_inside = mpl.text.Text(0.,0.,"inside :)", clip_on=True, clip_path=poly)
ax.add_artist(txt_inside)
# works perfectly
scatter = plt.scatter(*np.transpose([[0.1,0.1],[0.7,0.7]]), zorder=5, clip_path=poly)
ax.set_xlim(-1,1)
ax.set_ylim(-1,1)
plt.show()
Actual outcome
Expected outcome
I would expect the text outside :(
not to appear on the image.
Matplotlib version
This happens with matplotlib 2.0.0 with python 3.6.0 (installed with anaconda on linux). It also happens with matplotlib 1.5.3 with python 3.5.2 (same setup).