Skip to content

Per-axis autoscale strategy (auto / fixed / none) #61

@PierreRaybaut

Description

@PierreRaybaut

Context

Today, the AutoScale action — triggered either by the toolbar button (DoAutoscaleTool) or by a middle mouse button click (AutoZoomHandler) — always recomputes the bounds of all enabled axes from the items' boundingRect(), applying a global margin (autoscale_margin_percent).

There is no way to configure this behavior on a per-axis basis. For example, one cannot ask for the X axis to be auto-scaled while pinning the Y axis to a user-defined vmin/vmax range, or vice versa.

Proposed enhancement

Introduce a per-axis autoscale strategy (4 axes: Y_LEFT, Y_RIGHT, X_BOTTOM, X_TOP) with three possible modes:

Strategy Behavior
auto Current behavior: compute bounds from items + margin.
fixed Apply user-defined vmin / vmax bounds.
none Leave the axis untouched on do_autoscale().

Default for every axis is autofully backward compatible.

User-facing impact

UI

  • A new "Autoscale strategy" ChoiceItem is added to the axis-parameters dialog (already reachable via right-click on the axis scale → Axis parameters…).
  • When the strategy is fixed, the existing Min / Max fields of AxisParam are reused as the bounds applied on the next AutoScale.
  • The toolbar button and middle-click are unchanged on the surface: they now honor the strategy configured for each axis.

Programmatic API

  • New methods on BasePlot:
    • set_axis_autoscale_strategy(axis_id, strategy, vmin=None, vmax=None)
    • get_axis_autoscale_strategy(axis_id) -> tuple[str, float | None, float | None]
  • BasePlot.do_autoscale(replot=True, axis_id=None) signature is unchanged — it simply consults each axis's strategy before acting.
  • An explicit do_autoscale(axis_id=...) call also honors the strategy (including none).

Edge cases

  • Disabled axes: the existing if not self.axisEnabled(axis_id): continue guard at the start of do_autoscale keeps protecting inactive axes. The strategy is only consulted after this filter, so disabled axes have no side effects.
  • Dialog: edit_axis_parameters is only invoked on an enabled axis, so the new ChoiceItem is only exposed for axes that are actually in use.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions