# Info in \<TCanvas::MakeDefCanvas\>: created default TCanvas with name c1 but can't see it in windows

**URL:** <https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066>\
**Category:** Newbie\
**Created:** [July 2, 2024, 7:05am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066 "2024-07-02T07:05:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Closedbook](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/closedbook/32/36641_2.png) [@Closedbook](https://root-forum.cern.ch/u/Closedbook)\
**Post date:** [July 2, 2024, 7:05am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/1 "2024-07-02T07:05:29Z")

</div>

Here is a case in Guide:

```auto
TF1 efunc("efunc","exp([0]+[1]*x)",0.,5.);
efunc.SetParameter(0,1);
efunc.SetParameter(1,-1);
TH1F h("h","example histogram",100,0.,5.);
for (int i=0;i<1000;i++) {h.Fill(efunc.GetRandom());}
h.Draw();

```

and the result is:

```auto
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1

```

without any Histogram was shown.

_ROOT Version:_ 6.24.02  
_Platform:_ Ubuntu  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 2, 2024, 7:32am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/2 "2024-07-02T07:32:07Z")

</div>

Hi,

Can you modify your macro and create objects dynamically:

```auto
TF1 efunc("efunc","exp([0]+[1]*x)",0.,5.);
efunc.SetParameter(0,1);
efunc.SetParameter(1,-1);
auto h = new TH1F("h","example histogram",100,0.,5.);
for (int i=0;i<1000;i++) {h->Fill(efunc.GetRandom());}
h->Draw();

```

Otherwise object is destroyed before it can be painted.

---

<div class="post-metadata">

**Author:** ![Closedbook](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/closedbook/32/36641_2.png) [@Closedbook](https://root-forum.cern.ch/u/Closedbook)\
**Post date:** [July 2, 2024, 7:59am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/3 "2024-07-02T07:59:17Z")

</div>

Well, I don’t understand “object is destroyed”. The code is from here:[A ROOT Guide For Beginners](https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html#motivation-and-introduction). Even I tried

```auto
auto h = new TH1F("h","example histogram",100,0.,5.);

```

The result is still

```auto
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1

```

without any graph

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 2, 2024, 8:03am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/4 "2024-07-02T08:03:38Z")

</div>

When you creates histogram with:

```auto
TH1F h("h","example histogram",100,0.,5.);

```

it automatically destroyed when leaving function scope.  
Canvas rendering performed afterwards - therefore canvas does not “see” such object.

When object created dynamically with `new` operator, it will remain “alive” and can be rendered.

Does modified code works for you?

---

<div class="post-metadata">

**Author:** ![Closedbook](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/closedbook/32/36641_2.png) [@Closedbook](https://root-forum.cern.ch/u/Closedbook)\
**Post date:** [July 2, 2024, 8:53am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/5 "2024-07-02T08:53:54Z")

</div>

No, I still can’t get a histogram like this:

 ![TH1F_Example](https://root-forum.cern.ch/uploads/default/original/3X/8/b/8ba5ef8b1c5082ea62ec971c5d872d042fcdd338.png)  
it’s from ROOT Guide I mentioned above.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 2, 2024, 9:13am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/6 "2024-07-02T09:13:23Z")

</div>

Very strange, for me following macro works as expected:

[tut.cxx](https://root-forum.cern.ch/uploads/short-url/yWBk4IiWtr9lt0iMJyYlK0lkJuF.cxx) (219 Bytes)

---

<div class="post-metadata">

**Author:** ![Closedbook](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/closedbook/32/36641_2.png) [@Closedbook](https://root-forum.cern.ch/u/Closedbook)\
**Post date:** [July 12, 2024, 9:09am UTC](https://root-forum.cern.ch/t/info-in-tcanvas-makedefcanvas-created-default-tcanvas-with-name-c1-but-cant-see-it-in-windows/60066/7 "2024-07-12T09:09:57Z")

</div>

Well, I guess I find the solution. The reason is lacking Xming. Download it and for Win10 the DISPLAY Configuration is

```auto
export DISPLAY=localhost:0.0

```

and for Win11 is

```auto
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

```
