ScottPlot/ScottPlot

ScottPlot 5 anti-aliasing

kareem469 opened this issue · 8 comments

@swharden + other contributors, I don't know what magic you guys did in the 4.1.14, I changed the old line from:
item.fplot.RenderLowThenImmediateHighQuality(); for linking Verical Line Axis to

item.fplot.RenderRequest();

And it works amazing! Much better and smotther. See below the video, Thank you guys!!

Rec.0002.mp4

Originally posted by @EFeru in #1032 (comment)

How to achieve the same in Ver 5.0.34 ?

Hi @kareem469

RenderLowThenImmediateHighQuality()

This causes ScottPlot4 to render once with anti-aliasing off, then again with it on.

ScottPlot 5 does not need this, because it always renders with anti-aliasing on

Hi @swharden,

I am using the following code, but there is lag when graphs has large dataset (1 million datapoints)

private void FormsPlot1_MouseMove(object sender, MouseEventArgs e)
        {
            // this rectangle is the area around the mouse in coordinate units
            CoordinateRect rect = formsPlot1.Plot.GetCoordinateRect(e.X, e.Y, radius: 10);

            if (PlottableBeingDragged is null)
            {
                // set cursor based on what's beneath the plottable
                var lineUnderMouse = GetLineUnderMouse(e.X, e.Y);
                if (lineUnderMouse is null) Cursor = Cursors.Default;
                else if (lineUnderMouse.IsDraggable && lineUnderMouse is VerticalLine) Cursor = Cursors.SizeWE;
                else if (lineUnderMouse.IsDraggable && lineUnderMouse is HorizontalLine) Cursor = Cursors.SizeNS;
            }
            else
            {
                // update the position of the plottable being dragged
                if (PlottableBeingDragged is HorizontalLine hl)
                {
                    hl.Y = rect.VerticalCenter;
                    hl.Text = $"{hl.Y:0.00}";
                }
                else if (PlottableBeingDragged is VerticalLine vl)
                {
                    vl.X = rect.HorizontalCenter;

                    for(int iplot =0; iplot < formsplot.Length;iplot++)
                             verticallineAry[iplot].X =  vl.X;

                    //vl.Text = $"{vl.X:0.00}";
                }
                formsPlot1.Refresh();
            }
        }

Is it a scatter plot? That will be slow with one million points. Be sure to use a Signal or SignalXY plot for better performance

No, its SignalXY plots

Can you share a video or a reproducible code sample I can run on my machine to understand what the delay looks like? It's not super clear to me from the description why it's running slow, or if perhaps that speed is expected. Thanks for the additional information!

Here iam attaching the video,
One thing i observed here is. When huge data is there on the graph the dragging is lagging. But when i zoomed in then its getting smother while dragging.

WhatsApp.Video.2024-05-09.at.8.44.51.PM.mp4

I think it's 5 times slower than typical because you're updating 5 plots with millions of points every time the cursor is dragged. Perhaps you could only update the other plots OnMouseUp to keep performance high?

Only one time plotting the data using SignalXY(). And just updating verticale line when cursor dragged
Following is the sample code used

else if (PlottableBeingDragged is VerticalLine vl)
                {
                    vl.X = rect.HorizontalCenter;

                    for(int iplot =0; iplot < formsplot.Length;iplot++)
                             verticallineAry[iplot].X =  vl.X;

                    //vl.Text = $"{vl.X:0.00}";
                }