Skip to content

#3396 SignalXY with Inverted YAxis#3400

Merged
swharden merged 13 commits intoScottPlot:mainfrom
BrianAtZetica:#3396
Mar 6, 2024
Merged

#3396 SignalXY with Inverted YAxis#3400
swharden merged 13 commits intoScottPlot:mainfrom
BrianAtZetica:#3396

Conversation

@BrianAtZetica
Copy link
Contributor

This resolves issue #3396, allowing reversed X axes on SignalXY plots, and reversed Y axes on rotated SignalXY plots.

Code below was used in WPF sample project to verify various scenarios.
Note that inverted axis is currently missing axis labels according to #3397

using System;
using System.Linq;
using System.Windows;
using ScottPlot;

namespace Sandbox.WPF;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        double[] Xs = Enumerable.Range(1, 5000).Select(i => (double)i).ToArray();
        var signal = WpfPlot1.Plot.Add.SignalXY(Xs, Generate.Sin(count: 5000, oscillations: 4));
        //Test with normal X axis
        //WpfPlot1.Plot.Axes.SetLimitsX(left: 100.1, right: 5100);
        
        //Test with reversed X axis
        //WpfPlot1.Plot.Axes.SetLimitsX(left: 5100, right: 100.1);

        //Test with rotated SignalXY plot on normal Y axis
        //signal.Data.Rotated = true;
        //WpfPlot1.Plot.Axes.SetLimitsY(bottom: 100.1, top: 5100);

        //Test with rotated SignalXY plot on reversed Y axis
        signal.Data.Rotated = true;
        WpfPlot1.Plot.Axes.SetLimitsY(bottom: 5100, top: 100.1);

        //test with generic data type (not double) on normal X axis
        //int[] Xs = Enumerable.Range(1, 5000).Select(i => (int)i).ToArray();
        //int[] Ys = Enumerable.Range(1, 5000).Select(i => (int)i).ToArray();
        //var signal = WpfPlot1.Plot.Add.SignalXY(Xs,Ys);
        //WpfPlot1.Plot.Axes.SetLimitsX(left: 100.1, right: 5100);

        //test with generic data type (not double) on reversed X axis
        //int[] Xs = Enumerable.Range(1, 5000).Select(i => (int)i).ToArray();
        //int[] Ys = Enumerable.Range(1, 5000).Select(i => (int)i).ToArray();
        //var signal = WpfPlot1.Plot.Add.SignalXY(Xs,Ys);
        //WpfPlot1.Plot.Axes.SetLimitsX(left: 5100, right: 100.1);

    }
}

@swharden swharden linked an issue Mar 6, 2024 that may be closed by this pull request
@swharden
Copy link
Member

swharden commented Mar 6, 2024

Thanks so much @BrianAtZetica! I appreciate you opening #3396 and implementing an excellent fix in this PR 🚀

I recognize inverted axis labels aren't well-supported yet (#3397), but I'm happy to pop the hood on the tick system and try to figure that out wow, double win! I just noticed #3401 - way to go! 🚀 🚀

@swharden swharden merged commit b478930 into ScottPlot:main Mar 6, 2024
@BrianAtZetica BrianAtZetica deleted the #3396 branch March 7, 2024 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SP5 Rotated SignalXY with Inverted YAxis

2 participants