-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
bug: path effects in text() change text properties #2889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@pelson Can you take a look at this one too? |
Here's my build output.. just in case. https://gist.github.com/megies/9468079 |
Yep, just looking now. I'm very surprised about this one - the fact that it shows correctly is weird and I can't see any obvious bugs in my code. Right now I'm suspicious that there is an underlying bug in the renderer somewhere and that my change has exposed us to that - if that is the case, this could be particularly difficult to track down. I'll update on any progress. |
Btw, it doesn't take |
Thanks, that is worth knowing. |
P.S. Workaround: |
I think that might be the clue to the underlying problem - savefig, for some reason, has a different dpi to show. I'm wildly speculating that the smaller text is the correct size given the savefig's dpi, and the larger text is a fallout from the fact that its height is computed before the savefig call - essentially I think the bug here is that the OK text is too big. I'm speculating as I'm not sure what units "size" is in. The two possible definitions (taken from http://kyleschaeffer.com/development/css-font-size-em-vs-px-vs-pt-vs/):
With the resulting PNG from your code, OK has a height of 100px, and bad has 72px (plus a little extra for the actual path effect). @mdboom / @leejjoon - do either of you know what behaviour we actually want? |
The font size given to the |
It think It will be fixed by implementing the points_to_pixel method for the PathEffectRenderer class.
|
Suggested by @leejjoon. Fixes matplotlib#2889
#3081 resolves (not quite merged, but I will do it in the next couple of days unless somebody else beats me to it 😉 ) |
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 usingplt.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:
Note that the plot that shows after
savefig
has the text with correct size.Here's the buggy output png image:

The text was updated successfully, but these errors were encountered: