Title: check_figures_equal does not account for changed background colors in comparison · Issue #16275 · matplotlib/matplotlib · GitHub
Open Graph Title: check_figures_equal does not account for changed background colors in comparison · Issue #16275 · matplotlib/matplotlib
X Title: check_figures_equal does not account for changed background colors in comparison · Issue #16275 · matplotlib/matplotlib
Description: Bug report Bug summary When check_figures_equal is used as a decorator, the default behavior is to remove any background color during savefig, so plots which should have a different background color can't be properly compared. For exampl...
Open Graph Description: Bug report Bug summary When check_figures_equal is used as a decorator, the default behavior is to remove any background color during savefig, so plots which should have a different background colo...
X Description: Bug report Bug summary When check_figures_equal is used as a decorator, the default behavior is to remove any background color during savefig, so plots which should have a different background colo...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/16275
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"check_figures_equal does not account for changed background colors in comparison","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nWhen `check_figures_equal` is used as a decorator, the default behavior is to remove any background color during `savefig`, so plots which should have a different background color can't be properly compared.\r\n\r\nFor example, code that should produce a figure with a black background and the reference figure would both be saved as a white background.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nfrom matplotlib.testing.decorators import check_figures_equal\r\n\r\ndef create_test_figure_black_background(fig):\r\n axis = axis = fig.subplots()\r\n fig.set_facecolor('black')\r\n axis.bar(\r\n [0, 1, 2, 3, 4],\r\n [4, 5, 7, 9, 2],\r\n color=[\"red\", \"blue\", \"black\", \"yellow\", \"white\"],\r\n edgecolor=\"black\",\r\n )\r\n\r\n\r\n@check_figures_equal(extensions=[\"png\"])\r\ndef test_dark_background(test_figure, reference_figure):\r\n\r\n ref_ax = reference_figure.subplots()\r\n ref_ax.bar(\r\n [0, 1, 2, 3, 4],\r\n [4, 5, 7, 9, 2],\r\n color=[\"red\", \"blue\", \"black\", \"yellow\", \"white\"],\r\n edgecolor=\"black\",\r\n )\r\n\r\n create_test_figure_black_background(test_figure)\r\n```\r\n\r\n**Actual outcome**\r\n\r\nrunning with pytest shows a passing test, even though the test_fig should have a black background and the reference figure has a white background. These are both changed to white in `savefig`\r\n\r\n```\r\nC:\\Users\\Andrew\\Workspace\\TripleAgent\u003e pytest .\\triple_agent\\ -k test_dark_background\r\n================================================================ test session starts =================================================================\r\nplatform win32 -- Python 3.7.5, pytest-4.5.0, py-1.8.0, pluggy-0.9.0\r\nplugins: xdist-1.29.0, forked-1.0.2, cov-2.7.1\r\ncollected 1112 items / 1111 deselected / 1 selected\r\n\r\ntriple_agent\\tests\\test_plot_types.py . [100%]\r\n\r\n===================================================== 1 passed, 1111 deselected in 2.38 seconds ======================================================\r\n```\r\n\r\n**Expected outcome**\r\n\r\nExpect that backgrounds are preserved so that functionality for backgrounds can be tested.\r\n\r\nhttps://github.com/matplotlib/matplotlib/pull/15111 would likely solve the issue.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Win10\r\n * Matplotlib version: 3.1.0\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): TkAgg (i think?)\r\n * Python version: 3.7.5\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/andrewzwicky","@type":"Person","name":"andrewzwicky"},"datePublished":"2020-01-20T23:04:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/16275/matplotlib/issues/16275"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bf2671a6-8c56-01fa-d132-ce060ea9ab98 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC94:35B2CA:2A76A5:38BAF9:6A526E5B |
| html-safe-nonce | f1c8aebe6c5c7685db95256dbeb40f6e82f92b8f83ee82de731735a24405abf8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzk0OjM1QjJDQToyQTc2QTU6MzhCQUY5OjZBNTI2RTVCIiwidmlzaXRvcl9pZCI6IjkwMjczOTI4NjU2MDU2NzY2MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5c5f651a7bf03a011cb0e460b26e59f3bf5a4c49161d67e4b0b2907ebd276c4a |
| hovercard-subject-tag | issue:552544466 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/matplotlib/matplotlib/16275/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e403ef10b890cb0c0922387e02a02a6109789123d0ffcd723f351338552d634f/matplotlib/matplotlib/issues/16275 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e403ef10b890cb0c0922387e02a02a6109789123d0ffcd723f351338552d634f/matplotlib/matplotlib/issues/16275 |
| og:image:alt | Bug report Bug summary When check_figures_equal is used as a decorator, the default behavior is to remove any background color during savefig, so plots which should have a different background colo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andrewzwicky |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| 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