# TGraph and TH1F on same canvas, setting axis

**URL:** <https://root-forum.cern.ch/t/tgraph-and-th1f-on-same-canvas-setting-axis/50245>\
**Category:** Newbie\
**Created:** [June 2, 2022, 2:21pm UTC](https://root-forum.cern.ch/t/tgraph-and-th1f-on-same-canvas-setting-axis/50245 "2022-06-02T14:21:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fr4nk](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fr4nk/32/24294_2.png) [@Fr4nk](https://root-forum.cern.ch/u/Fr4nk)\
**Post date:** [June 2, 2022, 2:21pm UTC](https://root-forum.cern.ch/t/tgraph-and-th1f-on-same-canvas-setting-axis/50245/1 "2022-06-02T14:21:58Z")

</div>

Hi All,

I am currently trying to get a TGraph and TH1F to appear on the same canvas. As of now I am using:

```auto
auto c1 = new TCanvas("c1","c1",200,10,600,400);

...

h1->Draw("HIST");
TGraph* gr = new TGraph(c,x,y);
gr->Draw("*");

c1->Update();

```

to draw them both, but my graph is outside of the plot (not by much) and I would like to have them both fully visible. How can I go about doing this?

Thanks so much!

-Frank

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [June 2, 2022, 2:32pm UTC](https://root-forum.cern.ch/t/tgraph-and-th1f-on-same-canvas-setting-axis/50245/2 "2022-06-02T14:32:22Z")

</div>

```auto
auto c1 = new TCanvas("c1","c1",200,10,600,400);
...
gPad->DrawFrame(xmin,ymin,xmax,ymax); // define the right limits there

h1->Draw("HIST SAME");
TGraph* gr = new TGraph(c,x,y);
gr->Draw("*");

```

---

<div class="post-metadata">

**Author:** ![Fr4nk](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fr4nk/32/24294_2.png) [@Fr4nk](https://root-forum.cern.ch/u/Fr4nk)\
**Post date:** [June 2, 2022, 10:08pm UTC](https://root-forum.cern.ch/t/tgraph-and-th1f-on-same-canvas-setting-axis/50245/3 "2022-06-02T22:08:34Z")

</div>

@couet ,

Thank you so much!

-Frank
