-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Hide fully transparent text in PS output. #10166
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
Conversation
3daceff
to
7a9e51c
Compare
@@ -148,3 +149,13 @@ def test_determinism_all(): | |||
def test_determinism_all_tex(): | |||
"""Test for reproducible PS/tex output""" | |||
_determinism_check(format="ps", usetex=True) | |||
|
|||
|
|||
@image_comparison(baseline_images=['canonical'], extensions=["ps"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my knowledge, is there a reason to use single quotes for 'canonical' but double quotes for "ps" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waves his hand repeat after me: "This typo never existed"
def test_transparency(): | ||
fig, ax = plt.subplots() | ||
ax.plot([1, 2, 3]) | ||
# Reuse a standard test image, but chec that some additional transparent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above
7a9e51c
to
0491b56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a reasonable fix to me :) but I am no PS expert.
A (very) minor point is still itching me a bit: IIUC, with this fix, transparent text objects will not be present at all in the resulting PS file. So, it will not be possible anymore to modify these text objects afterwards directly in the PS file, will it not? I do not have a peculiar use case in mind, I just want to be sure that we do not overlook some behavior that might be useful to a few users.
fig, ax = plt.subplots() | ||
ax.set_axis_off() | ||
ax.plot([3, 2, 1], alpha=0) | ||
ax.text(.5, .5, "foo", alpha=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advise to put the text in the drawn area ([0, 2]x[1, 3], +/- the default margins). Something like ax.text(0.5, 1.5, "foo", alpha=0)
. Otherwise, the text instance is not visible, even with a non null alpha value, is it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, fixed
I am just reusing the same strategy as for paths, which are also not drawn at all. |
0491b56
to
6443aa9
Compare
Fair enough then :). |
Reading once more this line (and the next one...), I wonder if the special casing for text should not simply check if |
PS doesn't really support transparency (because the format itself doesn't, unless using some nonstandard extensions), but has some special casing for "fully transparent" (see e.g. "rgbFace is None" check in _draw_ps). Also implement the special-casing for text.
6443aa9
to
ee043fc
Compare
sounds good, improved test accordingly as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me :).
The added test files is a .pdf, that seems surprising to me... |
PS doesn't really support transparency (because the format itself
doesn't, unless using some nonstandard extensions), but has some special
casing for "fully transparent" (see e.g. "rgbFace is None" check in
_draw_ps).
Also implement the special-casing for text.
Closes #10163.
PR Summary
PR Checklist