fix: route hist/bar/scatter to active subplot (#2021)#2022
Merged
Conversation
plot() routes into the selected subplot via subplot_plot, but hist, bar, barh, and scatter built their plot_data into the figure-level plots array. When a subplot grid is active that array is never rendered, so those commands produced blank axes with no error. Add figure_t%relocate_last_plot_to_subplot, which mirrors the most recent figure-level plot into the active subplot, and call it from the hist, bar, barh, and scatter facade chokepoints. The figure-level slot is retained (not removed) because the add routines assume monotonically growing slots; the figure-level array is inert while a subplot grid is active.
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.
Closes #2021.
Problem
Switching a plotting call from
plot(x, y)tohist,bar,barh, orscatterinside a subplot grid produced blank white axes: the figurecompiled and ran without error, but no data appeared.
Root cause:
plot()routes into the selected subplot viasubplot_plot,while
hist/bar/scatterbuild theirplot_datainto the figure-levelplotsarray. When a subplot grid is active the renderer draws the subplotcells and never touches the figure-level array, so that data silently
vanishes.
Fix
Add
figure_t%relocate_last_plot_to_subplot, which mirrors the mostrecently added figure-level plot into the active subplot, and call it from
the
hist,bar/barh(bar_impl/barh_impl), andscatter(
scatter_2d_dispatch) chokepoints. The figure-level slot is retainedrather than removed because the add routines assume monotonically growing
slots; the figure-level array is inert while a subplot grid is active.
Verification
Build (serial to avoid the unrelated fpm parallel-build SIGABRT):
Regression test (extends test/state/test_stateful_subplots_routing.f90)
Failing before the fix:
Passing after the fix:
The test asserts
hist,bar, andscattereach land in the selectedsubplot (
subplot_plot_count == 1) and do not leak into the others.Rendering gate
Reproduced the issue's 2x2 grid (hist / bar / scatter / plot) to
/tmp/repro_2021.pdf.pdftotext -layoutshows every cell now carriesdata-derived tick ranges instead of the blank 0.0-1.0 default:
Full test suite passes (
OMP_NUM_THREADS=1 fpm test; no test reports FAIL).