Fix radar_plot axis ranges for asymmetric padding and constant metrics - #3
Closed
tonycoder-hub wants to merge 1 commit into
Closed
Fix radar_plot axis ranges for asymmetric padding and constant metrics#3tonycoder-hub wants to merge 1 commit into
tonycoder-hub wants to merge 1 commit into
Conversation
The upper padding was derived from the range after the lower bound had already been shifted, so the top of each axis was padded by 11% of the data range instead of 10%. A metric with the same value for every model also produced a zero-width range, which made matplotlib warn about singular limits and collapsed every other metric onto a single radius (or produced NaN coordinates when all metrics were constant). Co-authored-by: Tony Coder <407243179@qq.com>
tonycoder-hub
marked this pull request as ready for review
August 17, 2026 09:51
Owner
Author
|
Closing as stale — opened on or before 2026-08-17 and still unmerged. |
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
radar_plotderives each variable's axis range from the observed min/max plus 10% padding:Two things go wrong here:
Asymmetric padding. The second statement recomputes the span using the
minthat the first statement already shifted downwards, so the top of every axis is padded by 11% of the data range while the bottom is padded by 10%. Foraccuracyvalues of0.0and10.0the axis ends up as(-1.0, 11.1)instead of(-1.0, 11.0).Zero-width range for constant metrics. When a metric has the same value for every model the span is
0, so the padding is0too and the range collapses to a single point. Matplotlib then warnsAttempting to set identical low and high ylims makes transformation singular, and becauseComplexRadar._scale_datarescales all other variables intoranges[0], a constant first variable flattens every model onto the same radius — two models with different scores are drawn as identical shapes. If every metric is constant (e.g. a single model),_scale_datadivides by zero and the plotted coordinates becomeNaN.Fix
Compute the padding once from the original min/max, and fall back to a non-zero padding for variables that only take a single value.
Tests
Two tests added to
tests/test_viz.py, both failing before the change and passing after:test_range_padding_is_symmetricasserts the accuracy axis is(-1.0, 11.0).test_metric_with_identical_valuesasserts that whenaccuracyis identical across models butprecisionis not, the two plotted shapes are finite and still differ.black,isortandflake8(repo settings, line length 119) are clean on both changed files.