fix(plotting): add show=True parameter to PlotMethods for blocking display in scripts#831
Open
tanishkasinghhh wants to merge 1 commit into
Open
Conversation
…play in scripts camelot.plot(table).show() calls matplotlib's Figure.show(), which returns immediately in non-interactive (Agg / script) backends — the window closes before the user sees it (issue camelot-dev#296). The correct entry point for blocking display in a plain Python script is plt.show(block=True). Users reported that passing block=True to the Figure directly raised TypeError, because Figure.show() does not accept that argument. Fix: add show=False to PlotMethods.__call__(). When show=True, call plt.show(block=True) after creating the figure. The default remains False so all existing callers (Jupyter notebooks, image-comparison tests, file-save paths) are unaffected. Usage after this change: fig = camelot.plot(tables[0], kind='grid', show=True) Closes camelot-dev#296
Collaborator
|
Triage: the failing check here is Two things ruff flags in the new test file:
pre-commit is a hard-required gate here, so once those two are addressed CI should go green. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
camelot.plot(table).show()calls matplotlib'sFigure.show(), whichreturns immediately in non-interactive (Agg / script) backends — the
window closes before the user can see it (issue #296).
The correct blocking entry point for scripts is
plt.show(block=True).However,
Figure.show()does not accept ablockargument, so userscannot work around it without calling
plt.show()separately — and thisis not obvious from the camelot API.
Fix
Add
show=FalsetoPlotMethods.__call__(). Whenshow=True, callplt.show(block=True)after creating the figure.The default is
Falseto preserve existing behaviour for all callers(Jupyter notebooks, image-comparison tests, file-save paths).
Changes
camelot/plotting.pyshow=Falsekwarg; callplt.show(block=True)when set (only on non-filename paths)tests/test_plot_show.pyplt.shownot called by default; called withblock=Truewhen requested; figure is still returned; save-to-file path unaffectedTests
Closes #296
Prepared with AI assistance (Claude Code). Every change reviewed and understood line-by-line.