DoubleXAxis

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

Bases: DoubleAxisBase

Add a top x-axis sharing the primary y-axis.

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 – Bottom and top axis colours, using the same parsing rules as DoubleYAxis. Accepts a list, tuple, comma-separated string or None.

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

The returned Axes supports plotting against an independent top x scale. Legend handling and colour validation share a common base with DoubleYAxis.