# Canvas without histogram from ROOT Guide For Beginners

**URL:** <https://root-forum.cern.ch/t/canvas-without-histogram-from-root-guide-for-beginners/32841>\
**Category:** Newbie\
**Created:** [February 21, 2019, 12:18pm UTC](https://root-forum.cern.ch/t/canvas-without-histogram-from-root-guide-for-beginners/32841 "2019-02-21T12:18:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AOS](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@AOS](https://root-forum.cern.ch/u/AOS)\
**Post date:** [February 21, 2019, 12:18pm UTC](https://root-forum.cern.ch/t/canvas-without-histogram-from-root-guide-for-beginners/32841/1 "2019-02-21T12:18:48Z")

</div>

Hello all,  
I took this guide [https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html#storing-root-objects](https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html#storing-root-objects) and tried 7.1 Storing ROOT Objects.

When try this macros using .x read\_from\_file.C:

```auto
void read_from_file(){

    // Let's open the TFile
    TFile in_file("my_rootfile.root");

    // Get the Histogram out
    TH1F* h;
    in_file.GetObject("my_histogram",h);

    // Draw it
    auto myCanvas = new TCanvas();
    h->DrawClone();
}

```

it gives canvas without histogram.

If use “online” method

```auto
> root my_rootfile.root
root [0]
Attaching file my_rootfile.root as _file0...
root [1] _file0->ls()
TFile** my_rootfile.root
 TFile* my_rootfile.root
  KEY: TH1F my_histogram;1 My Title
root [2] my_histogram->Draw()

```

everything is fine.

What I do wrong? I use Ubuntu 18.04.1 LTS with ROOT 6.10.04

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [February 21, 2019, 12:23pm UTC](https://root-forum.cern.ch/t/canvas-without-histogram-from-root-guide-for-beginners/32841/2 "2019-02-21T12:23:14Z")

</div>

Instead of `h->DrawClone();`, use: `h->SetDirectory(gROOT); h->Draw();`

---

<div class="post-metadata">

**Author:** ![AOS](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@AOS](https://root-forum.cern.ch/u/AOS)\
**Post date:** [February 21, 2019, 2:30pm UTC](https://root-forum.cern.ch/t/canvas-without-histogram-from-root-guide-for-beginners/32841/3 "2019-02-21T14:30:12Z")

</div>

Works! Thank! How did you understand that you need to write exactly this?
