Back-rescale previous (minor) curves from latest

For the "pin to target major/target curve" overlay method, this finally
solves the longstanding issue of ensuring that any new minor curve,
which requires and increase in the major/target curve y-range, also
re-scales all previously scaled minor curves retroactively. Thus we now
guarantee that all minor curves are correctly "pinned" to their
target/major on their earliest available datum **and** are all kept in
view.
log_linearized_curve_overlays
Tyler Goodlet 2023-02-27 17:16:33 -05:00
parent 6601dea8cc
commit c1ea8552ac
1 changed files with 21 additions and 5 deletions

View File

@ -651,18 +651,34 @@ def overlay_viewlists(
# TODO: rescale all already scaled curves to # TODO: rescale all already scaled curves to
# new increased range for this side. # new increased range for this side.
# for ( for _view in scaled:
# view, _yref, _ymn, _ymx = scaled[_view]
# (yref, ymn, ymx) new_ymn = _yref * (1 + r_dn_minor)
# ) in scaled.items():
# pass # TODO: is there a faster way to do this
# by mutating state on some object
# instead?
scaled[_view] = (_yref, new_ymn, _ymx)
ymx = y_start * (1 + r_major_up_here) ymx = y_start * (1 + r_major_up_here)
if ymx < y_max: if ymx < y_max:
# set the `scaled: dict` entry to ensure
# that this minor curve will be entirely in
# view.
ymx = y_max ymx = y_max
r_up_minor = (ymx - y_start) / y_start r_up_minor = (ymx - y_start) / y_start
# adjust the target-major curve's range to
# (log-linearly) include this extra range by
# applying the inverse transform of the
# minor.
mx_ymx = y_ref_major * (1 + r_up_minor) mx_ymx = y_ref_major * (1 + r_up_minor)
for _view in scaled:
_yref, _ymn, _ymx = scaled[_view]
new_ymx = _yref * (1 + r_up_minor)
scaled[_view] = (_yref, _ymn, new_ymx)
if debug_print: if debug_print:
print( print(
f'Minor SCALARS {viz.name}:\n' f'Minor SCALARS {viz.name}:\n'