# Picture lost in canvas and function

**URL:** <https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478>\
**Category:** ROOT\
**Created:** [March 11, 2024, 9:52am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478 "2024-03-11T09:52:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xlinbo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xlinbo/32/35897_2.png) [@xlinbo](https://root-forum.cern.ch/u/xlinbo)\
**Post date:** [March 11, 2024, 9:52am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478/1 "2024-03-11T09:52:51Z")

</div>

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:

```auto
 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.

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [March 11, 2024, 10:14am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478/2 "2024-03-11T10:14:06Z")

</div>

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")`?

---

<div class="post-metadata">

**Author:** ![xlinbo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xlinbo/32/35897_2.png) [@xlinbo](https://root-forum.cern.ch/u/xlinbo)\
**Post date:** [March 11, 2024, 10:57am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478/3 "2024-03-11T10:57:40Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [March 11, 2024, 11:48am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478/4 "2024-03-11T11:48:03Z")

</div>

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:

> [@ROOT on Windows 11 WSL2 / WSLg](https://root-forum.cern.ch/t/root-on-windows-11-wsl2-wslg/48348/7):
>
> So I tried staying with WSL2 and using VcXsrv, and it works fine, as far as I have tested. I don’t know if behind curtains WSL is complaining for having 2 GUI servers, but it seems to work slight_smile Just for completeness, when using WSL2 and VcXsrv (don’t know with Xming), adding these lines to .bashrc is needed: export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2\>/dev/null):0 export LIBGL\_ALWAYS\_INDIRECT=1 but is not enough (in either Windows 10 or 11). When starti…

---

<div class="post-metadata">

**Author:** ![xlinbo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xlinbo/32/35897_2.png) [@xlinbo](https://root-forum.cern.ch/u/xlinbo)\
**Post date:** [March 11, 2024, 11:51am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478/5 "2024-03-11T11:51:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [March 25, 2024, 11:52am UTC](https://root-forum.cern.ch/t/picture-lost-in-canvas-and-function/58478/6 "2024-03-25T11:52:11Z")

</div>

Closed on March 25, 2024, 11:52am UTC

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