Skip to content

Controls: Simplify how to share axes #2372

@swharden

Description

@swharden

Wiring together two plots with a shared axis is a pain!

This works now

This is how I do it currently as described by https://scottplot.net/faq/shared-axes/

formsPlot1.AxesChanged += (s, e) =>
{
    formsPlot2.Configuration.AxesChangedEventEnabled = false;
    formsPlot2.Plot.MatchAxis(formsPlot1.Plot, horizontal: true);
    formsPlot2.Refresh();
    formsPlot2.Configuration.AxesChangedEventEnabled = true;
};

formsPlot2.AxesChanged += (s, e) =>
{
    formsPlot1.Configuration.AxesChangedEventEnabled = false;
    formsPlot1.Plot.MatchAxis(formsPlot2.Plot, horizontal: true);
    formsPlot1.Refresh();
    formsPlot1.Configuration.AxesChangedEventEnabled = true;
};

Could it be easier?

Something like this could handle the event twiddling and the refresh too

formsPlot1.AxesChanged += (s, e) => 
{
    formsPlot1.CopyAxesFrom(formsPlot1.Plot, horizontal: true, vertical: false);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions