DoubleXYAxis

class stonerplots.DoubleXYAxis(ax: Axes | None = None, legend: bool = True, loc: str | int = 'best', colours: list | tuple | str | None = None, switch_to_xy2: bool = True)

Bases: DoubleAxisBase

Add independent top x and right y axes for a second dataset.

Parameters:
  • ax – Primary axes, or the current axes if None.

  • legend – Merge legends onto the primary axes on exit. Defaults to True.

  • loc – Merged legend location. Defaults to “best”.

  • colours – Primary (bottom/left) and secondary (top/right) colours, using the same parsing rules as DoubleYAxis. Accepts a list, tuple, comma-separated string or None.

  • switch_to_xy2 – Make the returned secondary axes current within the context and restore the previous axes on exit. Defaults to True.

The context returns one Axes with both coordinates independent of the primary axes. It remains aligned with the primary plot during layout and resizing. Legend handling and colour validation share a common base with DoubleYAxis.