Does anyone know how to let matplotlib (V3.3.0) to show a figure and then continue executing the rest of the Python script when executed from Python.NET PythoneEngine.Exec(script) in a C# app?
plt.show(block=False)
This works as expected.
When I run the same script directly from Python interpreter V3.8.4 (64 bit) it works. So, I think that all the libraries are installed correctly. I'm using the following code:
class Program
{
    static void Main(string[] args)
    {
        PythonEngine.Initialize();
        using (Py.GIL())
        {
            var script = "import matplotlib.pyplot as plt\n"
                         + "import numpy as np\n"
                         + "x = np.arange(0.0, 2.0, 0.01)\n"
                         + "y = np.sin(2 * np.pi * x)\n"
                         + "fig, ax = plt.subplots()\n"
                         + "ax.plot(x, y)\n"
                         + "plt.show(block=False)\n";
            PythonEngine.Exec(script);
        }
        
        Console.ReadLine();
        PythonEngine.Shutdown();
    }
}
This shows a blank window when PythoneEngine.Exec() finishes. The figure window itself is unresponsive.
If I remove block=False from the plt.show(block=False), then it shows the sine curve correctly. But I have to close the figure window to let it continue.
I'm using .NET Framework 4.8 on Windows 10 (64 bit).
 
     
    