Picture lost in canvas and function

I’m using Windows 11 on an x64 architecture, running Ubuntu 22.04.3 LTS. My ROOT version is 6.30.04. I’ve just installed ROOT without making any modifications, but when I try to use the canvas and draw functions, no image is displayed. Is there something wrong with the installation? Below is a simple code snippet:

 TCanvas* another_canvas = new TCanvas("c2","my canvas",100,250,500,50)
root [12] f1 = new TF1("f1","sin(x)",0,5);
root [13] f1->Draw();

After running the code, no image is displayed.

Hello @xlinbo, welcome to the ROOT forum!

It seems you are using the Windows subsystem for Windows, right? This setup is is very uncommon, and it’s quite likely that the problem is related to this installation method.

Can you not use a native Linux? What happens if you draw the canvas explicitly, like another_canvas->Draw()? Would it be an acceptable workaround to just save the plot to a file, like another_canvas->SaveAs("plot.pdf")?

Thank you very much for your reply! I am indeed using WSL2 to run a Linux environment through the subsystem. I will try running it in a native Linux environment later, and thank you for your suggestion!

If you want to keep running it through WSL2, you need to install an “X server”, e.g. VcXsrv (google it and get it from sourceforge), and have this server running before opening the linux environment. See here some instructions for WSL2:

Thank you for the helpful advice! I appreciate your reply!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.