Skip to content

SignalPlot fails when arrays contain double.NaN #546

@bukkideme

Description

@bukkideme

Describe the bug
When I create a second SignalPlot using a List, it is only shown after zoom in. I guess I only miss something basic...?

To Reproduce
Create a SignalPlot with rand numbers, then a List based on this array, and send it to a second SignalPlot.

// include code to help us reproduce this bug
using MathNet.Numerics.Statistics;
using ScottPlot;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ScottPlot_PlotSignalNotShown
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Random rand = new Random(0);
            int pointCount = (int)1e5;
            double[] array1 = DataGen.RandomWalk(rand, pointCount);
            
            formsPlot1.plt.PlotSignal(array1, 1, 0, 0, color: Color.Blue, 2, 6, "Signal 1");
            
            List<double> smooth = new List<double>();
            MovingStatistics moving_aver = new MovingStatistics(24);
            foreach (double value in array1)
            {
                moving_aver.Push(value);
                smooth.Add(Math.Round(moving_aver.Variance));
            }

            formsPlot1.plt.PlotSignal(smooth.ToArray(), 1, 0, 0, color: Color.Green, 2, 6, "Signal 1 variance");

            formsPlot1.plt.Legend(true, fontSize: 18, location: legendLocation.upperRight);
            formsPlot1.Render();
        }
    }
}

Screenshots
image

After zoom in:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions