Skip to content
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

Explicitly clear Matplotlib figure to remove warning about auto-removal of overlapping axes #5857

Merged
merged 2 commits into from
Aug 16, 2023

Conversation

ianthomas23
Copy link
Member

Running the Matplotlib tests currently gives a MatplotlibDeprecationWarning as follows:

$ pytest -v holoviews/tests/plotting/matplotlib/test_renderer.py::MPLRendererTest::test_get_size_row_plot
<snip>                                                                                                                    
holoviews/tests/plotting/matplotlib/test_renderer.py::MPLRendererTest::test_get_size_row_plot PASSED                               [100%]

============================================================ warnings summary ============================================================
holoviews/tests/plotting/matplotlib/test_renderer.py::MPLRendererTest::test_get_size_row_plot
  /Users/iant/github/holoviews/holoviews/plotting/mpl/plot.py:958: MatplotlibDeprecationWarning: Auto-removal of overlapping axes is deprecated since 3.6 and will be removed two minor releases later; explicitly call ax.remove() as needed.
    subaxes = [plt.subplot(self.gs[ind], projection=proj)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================================== 1 passed, 1 warning in 0.45s ======================================================

This PR explicitly clears the current Matplotlib figure using plt.clf(), which deletes all of its axes objects. The fix is added before the start of a loop that potentially calls plt.subplot multiple times as the clearing of the current figure only needs to occur the first time around.

With this fix all the Matplotlib tests pass locally without producing a warning. It does need to be checked by a HoloViews expert to confirm there won't be any unwanted side-effects.

@hoxbro hoxbro added this to the 1.17.1 milestone Aug 16, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2023

Codecov Report

Merging #5857 (8d07a19) into main (75d510f) will increase coverage by 0.10%.
Report is 3 commits behind head on main.
The diff coverage is 88.67%.

@@            Coverage Diff             @@
##             main    #5857      +/-   ##
==========================================
+ Coverage   88.24%   88.34%   +0.10%     
==========================================
  Files         309      310       +1     
  Lines       63926    63927       +1     
==========================================
+ Hits        56412    56477      +65     
+ Misses       7514     7450      -64     
Flag Coverage Δ
ui-tests 23.39% <26.41%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
holoviews/ipython/widgets.py 0.00% <0.00%> (ø)
holoviews/core/data/__init__.py 86.53% <92.85%> (ø)
holoviews/core/ndmapping.py 79.92% <100.00%> (+0.03%) ⬆️
holoviews/ipython/archive.py 44.79% <100.00%> (+5.66%) ⬆️
holoviews/ipython/magics.py 65.36% <100.00%> (+0.61%) ⬆️
holoviews/operation/downsample.py 84.90% <100.00%> (+84.90%) ⬆️
holoviews/plotting/bokeh/util.py 66.94% <100.00%> (+0.04%) ⬆️
holoviews/plotting/mpl/plot.py 60.74% <100.00%> (+0.05%) ⬆️
holoviews/plotting/plotly/renderer.py 56.25% <100.00%> (ø)
holoviews/tests/operation/test_downsample.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hoxbro hoxbro requested a review from philippjfr August 16, 2023 14:27
@philippjfr
Copy link
Member

Thanks, makes sense to me!

@hoxbro hoxbro merged commit 73ab2a4 into holoviz:main Aug 16, 2023
14 checks passed
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants