Description
After encountering strange behavior across matplotlib versions 1.3/1.4 in our image tests in @obspy and a couple of hours of debugging and git bisect
ing roughly a dozen steps through matplotlib git repo I have pinpointed a problem with path effects..
When using path effects in plt.text()
and using plt.savefig("...png")
the text properties get changed in a strange way. What I experienced is that font size gets decreased by roughly 25% when I used a path effect on text.
The commit that introduces the bug is 3d31865. The parent commit d5f9876 shows the expected behavior.
The following shows a minimal test case to reproduce:
import matplotlib
matplotlib.use("TKAGG")
import matplotlib.pyplot as plt
import matplotlib.patheffects as PathEffects
plt.text(0, 0, "BAD", size=100,
#path_effects=[PathEffects.withStroke(linewidth=3,
# foreground="red")])
# EDIT: even `Normal()` exposes the bug
path_effects=[PathEffects.Normal()])
plt.text(0, 0, " OK", size=100)
plt.savefig("/tmp/patheffects_bug.png")
plt.show()
Note that the plot that shows after savefig
has the text with correct size.