question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to speed up rendering of many plots

See original GitHub issue

ScottPlot Version: 4.1.16 Operating System: WIN10 Application Type: WinForms

Issue Description: In my application I create a list of plots that are linked. Basically I allow the user to create as many plots as he wants. The drawback is that with the increased number of plots and signals the interaction with the plots becomes slower and slower.

Questions: Do you have suggestions on what to do to speed up the rendering process? (compute in parallel, threads, use GPU, etc.)

Below is a snippet of the code that is excuted every time the use interracts with one of the plots. Works decent up to 4 plots and moderate number of signals (up to 10 signals/plot, and let’s say up to 10000 points/signal). However, above that I start to feel degradation of speed that affects user interraction. Using Parallel.ForEach doesn’t help much. Especially for the Vertical Lines dragged linked I get strange delayed behavior if I use Parallel.ForEach.

  • In the past I have used a graph tool that used the Arction engine. It was very fast, I must admit even, with many many plots. It is using DirectX in the background. Maybe we can learn from it.

  • Then I was triggered by Matlab, which I intensively use. Matlab uses OpenGL to render and it renders quite fast. Do you think OpenGL would increase rendering time in C#, see: https://github.com/dwmkerr/sharpgl If we could use it in ScottPlot, then 3D plots and surface plots will become possible too. What is your opinion on that? This topic is related to #1113

  • Or is there a posibility to use the GPU power in C# for rendering?

  • For me any option that helps to speed up the rendering of many plots is ok. Because only 20% of processing power is used at the moment on my laptop. So, I think we can do more to use the available resources to our advantage.

Other links that I found:

For X Axes linked:

public static void OnAxesChanged(object sender, EventArgs e)
{
    FormsPlot changedPlot = (FormsPlot)sender;
    axisXMin = changedPlot.Plot.GetAxisLimits().XMin;
    axisXMax = changedPlot.Plot.GetAxisLimits().XMax;

    foreach (FormTimePlot tp in timePlot)
    {
        if (tp.formsPlot == changedPlot)
            continue;

        // Disable events briefly to avoid an infinite loop
        tp.formsPlot.Configuration.AxesChangedEventEnabled = false;
        tp.formsPlot.Plot.SetAxisLimits(xMin: axisXMin, xMax: axisXMax);
        tp.formsPlot.Render();
        tp.formsPlot.Configuration.AxesChangedEventEnabled = true;
    }

    //Parallel.ForEach (timePlot, tp =>
    //{
    //    // Disable events briefly to avoid an infinite loop
    //    tp.formsPlot.Configuration.AxesChangedEventEnabled = false;
    //    tp.formsPlot.Plot.SetAxisLimits(xMin: axisXMin, xMax: axisXMax);
    //    tp.formsPlot.Render();
    //    tp.formsPlot.Configuration.AxesChangedEventEnabled = true;
    //});

}

For Vertical Lines dragged linked:

public static void OnAxesDragged(object sender, EventArgs e)
{
    VLine changed_Line = (VLine)sender;
    vPosition = changed_Line.X;

    foreach (FormTimePlot tp in timePlot)
    {
        if (tp.vLine == changed_Line)
            continue;

        tp.vLine.X = vPosition;
        tp.formsPlot.Configuration.AxesChangedEventEnabled = false;
        tp.formsPlot.RenderRequest();
        tp.formsPlot.Configuration.AxesChangedEventEnabled = true;                
    }

    //Parallel.ForEach(timePlot, tp =>
    //{
    //    tp.vLine.X = vPosition;
    //    tp.formsPlot.Configuration.AxesChangedEventEnabled = false;
    //    tp.formsPlot.Render();
    //    tp.formsPlot.Configuration.AxesChangedEventEnabled = true;
    //});
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
swhardencommented, Aug 3, 2021

@EmanuelFeru a while back I did some experimentation with SkiaSharp and plotting and it was fantastic performance https://github.com/swharden/quickplot

The problem at that time was the build process was non-trivial (compared to System.Drawing which just seemed to work everywhere).

With #1036 and discussion emerging there this issue is on its way to being solved! I’ll close this issue for now, and hopefully tackle this around the time .NET 6 and Microsoft.Maui.Graphics.Skia is out of preview 👍

1reaction
EFerucommented, Jul 19, 2021

I will do some more tries. For now I will close the topic. Thank you for your answers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ways to speed up rendering of many figures
Ways to speed up rendering of many figures · Pull latest Bokeh git repo: https://github.com/bokeh/bokeh · Launch “pivot” example app, e.g: bokeh ...
Read more >
14 Tips for Faster Rendering in After Effects
Let's speed up your render times—and workflow—in After Effects with these handy settings and hardware tips. · 1. Enable Multi-Frame Rendering · 2....
Read more >
How can I make matplotlib plot rendering faster
Two possible solutions: Don't show a scatter plot, but a hexbin plot instead. Use blitting. (In case someone wonders about the quality of ......
Read more >
Ways to speed up rendering / plotting performance
Hi everyone, I'm looking for all kinds of ways to speed up the rendering of plots in JavaScript, maybe we can collect some...
Read more >
Speed up plot rendering in Python/Matplotlib
In Matplotlib, you can assign an attribute to any plot element called rasterized=True . It will convert only that graphical element to raster, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found