Skip to content

Expose ImPlot::SetAxes() to allow explicit X/Y axis pairing for plot series #2620

@foodfo

Description

@foodfo

Description

Currently in DearPyGui, series can be added as children of any of the following axes — mvXAxis, mvXAxis2, mvXAxis3, mvYAxis, mvYAxis2, mvYAxis3 — but there is no way to explicitly control the pairing between X and Y axes for a given series.

It is not entirely clear to how DPG assigns axis pairings when multiple axes exist - the behavior appears inconsistent depending on which order the axes were created using dpg.add_plot_axis(), and what the hide/show state is when assigning via dpg.add_line_series(), etc.

It appears that the ImPlot API has supported explicit axis pairing since v0.13 via ImPlot::SetAxes(ImAxis x_idx, ImAxis y_idx), called immediately before each plot call. This is not currently exposed in DPG.

Proposed API

Expose this as an additional DPG method while leaving current default rank-based behavior intact. Users who do not call it get existing behavior. Users who need explicit control can override it:

dpg.set_plot_axes(series_tag, x_axis=dpg.mvXAxis2, y_axis=dpg.mvYAxis1)

Or as optional parameters on series add functions:

dpg.add_line_series(..., x_axis=dpg.mvXAxis2, y_axis=dpg.mvYAxis1)

Use Case

I'm building a multi-axis time series viewer where users drag and drop data columns onto specific axes. With explicit axis pairing exposed, when a user drags a series onto a specific axis I can detect how many alternative axes are currently enabled/visible and prompt the user to select the destination pairing — for example, drag onto Y2 and get a popup asking whether to plot against X1, X2, or X3. This is currently impossible because the pairing is assigned automatically with no way to override it after the fact.

Workarounds
I have not found reliable workarounds for the default behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions