Title: PDF backend can now do alpha on hatches. by mnmelo · Pull Request #17049 · matplotlib/matplotlib · GitHub
Open Graph Title: PDF backend can now do alpha on hatches. by mnmelo · Pull Request #17049 · matplotlib/matplotlib
X Title: PDF backend can now do alpha on hatches. by mnmelo · Pull Request #17049 · matplotlib/matplotlib
Description: PR Summary Studied a bit of .PDF and I got this working. Turns out the transparency graphics states (ExtGState) weren't being taught to the hatch pattern writing routine. This completes the fix of hatch alpha on SVG and PDF (#16883). Furthermore, I noticed, after the previous PR (#16890), that there was a bit of mixed behavior between 2 cases: 1. when a Patch edgecolor (and therefore its hatch_color) has alpha; or 2. when the entire Patch has alpha. Case 1 is what I had tried to fix in #16890; however, the test I was relying on was of case 2. Case 2 is more logically and elegantly rendered by doing edge+hatch full opacity and then within an object with alpha. Digging a bit deeper I found I could implement this case 2 behavior by extending the forced_alpha concept to the SVG and PDF renderers: if the parent Patch or Collection has a global alpha, ignore the ones of the elements. I updated two test_artist.py tests to better cover these cases (no added baselines images). The following images showcase the results of the SVG and PDF hatching test, after conversion to PNG. The rightmost, orange-tinted shapes are the ones where alpha was set; on the top diamond only on the edgecolor, on the bottom one on the entire Rectangle: SVG Notice in the top-right shapes how the edge and face/hatch overlap. This no longer occurs if the alpha is set on the entire object (but then the fill is also affected). PDF Notice again in the top-right shape that PDF is cleaner in handling the edge overlap with the face and hatch of the same Patch. It's rendered as a group that is internally opaque (the edge completely occludes the fill and hatch) but still transparent at the edges (I guess this is called a knockout group? I didn't add anything specific to this end). I'm not sure SVG could allow for this but would be cool/cleaner if it did. Feedback appreciated. PR Checklist Has Pytest style unit tests Code is Flake 8 compliant New features are documented, with examples if plot related Documentation is sphinx and numpydoc compliant Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
Open Graph Description: PR Summary Studied a bit of .PDF and I got this working. Turns out the transparency graphics states (ExtGState) weren't being taught to the hatch pattern writing routine. This completes the fix...
X Description: PR Summary Studied a bit of .PDF and I got this working. Turns out the transparency graphics states (ExtGState) weren't being taught to the hatch pattern writing routine. This completes the...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/17049
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:99e1b741-5fa4-f631-debc-fd1499077e2a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AB6E:164416:A50A5:DB86F:6A52BE20 |
| html-safe-nonce | 815045512a3ceb6875edceab9d8782e38ddeda10c292780bdf0c9661abdb1409 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjZFOjE2NDQxNjpBNTBBNTpEQjg2Rjo2QTUyQkUyMCIsInZpc2l0b3JfaWQiOiI1MTY0NzQ3NDI5OTA4NzU4MDQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 51496693a3e3b6f530ce4ca1234077fad2efd2aaba10cb3e52fa62b7266fa6da |
| hovercard-subject-tag | pull_request:399775470 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/17049/files |
| twitter:image | https://avatars.githubusercontent.com/u/11721337?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/11721337?s=400&v=4 |
| og:image:alt | PR Summary Studied a bit of .PDF and I got this working. Turns out the transparency graphics states (ExtGState) weren't being taught to the hatch pattern writing routine. This completes the fix... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width