Repository navigation
2D plots: draw into given axes, optional show, return the figure - #29
Merged
Merged
Conversation
All matplotlib 2D plots of the Workbench take ax (axes to draw into, e.g. one subplot) and show (False: return without showing, to add to the plot first), and return (fig, ax), like the 3D plots already take show and return their plotter: - plot_structural_model_2D, plot_fault_model_2D - plot_cross_section_2D (axes: two axes, one per panel; returns (fig, axes)), plot_cross_section_difference_2D - plot_variable_along_line, plot_variable_time_series Defaults are unchanged (new figure, shown), so the Workbench inspectors behave as before. A figure the plot creates is laid out as before; a caller's figure is left for the caller to arrange. Shared helpers in core/utility/figures.py. Along-line and fault-domain colorbar no longer use pyplot's current figure. Use case: model sections drawn on top of an outcrop photo, and method comparisons in one subplot grid (a student's notebooks needed a local backend change for this, which a later merge dropped). Manuals list the options with examples; tests cover drawing into given axes, show=False and the default. Co-Authored-By: Claude Opus 5.5
luepges
reviewed
Dec 3, 2026
luepges
approved these changes
Dec 3, 2026
javoha
added a commit
that referenced
this pull request
Dec 4, 2026
Brings in #29 (2D plots: ax, show, return the figure). Conflicts in the cross-section plots: keep the plane titles of this branch with the show/return of main; tests: keep both. Co-Authored-By: Claude Opus 5.5
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.
What
All matplotlib 2D plots of the Workbench can now draw into existing axes and skip showing the figure, and they return the figure and axes. This is the same pattern as the 3D plots, which already take
showand return their plotter.plot_structural_model_2Dax,show→(fig, ax)plot_fault_model_2Dax,show→(fig, ax)plot_cross_section_2Daxes(two, one per panel),show→(fig, axes)plot_cross_section_difference_2Dax,show→(fig, ax)plot_variable_along_lineax,show→(fig, ax)plot_variable_time_seriesax,show→(fig, ax)Why
Without this, users can't combine our 2D plots with their own matplotlib content. Two examples:
A student's example notebooks do both. They relied on a local edit of
plot_structural_model_2Don her branch, and a later merge of main dropped that edit, so the notebooks broke. With this PR her calls (fig, ax = plot_structural_model_2D(..., show=False)andax=ax, show=False) work as written.Details
ax/show, each plot still opens a new figure and shows it. The Workbench inspectors ignore the return value, so they behave as before.tight_layout). When the caller passes an axes, arranging the figure is left to the caller.figure_and_axesandfinish_figurelive in the newcore/utility/figures.py.plot_variable_along_lineand the fault-domain colourbar ofplot_fault_model_2Dused pyplot's current figure. They now draw on their own figure/axes, so they no longer end up on the wrong figure whenaxis given.StructuralFrame.plot_scalar_field_section/plot_age_mask_sectionand the matplotlib plots in the meshing code. They are not Workbench plots.Tests
show=Falsedoes not show the figure;plot_cross_section_2Drefuses anaxeslist that doesn't have exactly two axes.🤖 Generated with Claude Code