# Plotting two TGraphs from a different root file on the same graph

**URL:** <https://root-forum.cern.ch/t/plotting-two-tgraphs-from-a-different-root-file-on-the-same-graph/38786>\
**Category:** Newbie\
**Created:** [April 9, 2020, 1:10pm UTC](https://root-forum.cern.ch/t/plotting-two-tgraphs-from-a-different-root-file-on-the-same-graph/38786 "2020-04-09T13:10:47Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![KatR](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@KatR](https://root-forum.cern.ch/u/KatR)\
**Post date:** [April 9, 2020, 2:35pm UTC](https://root-forum.cern.ch/t/plotting-two-tgraphs-from-a-different-root-file-on-the-same-graph/38786/5 "2020-04-09T14:35:04Z")

</div>

Not in tutorials, although what I was basing the code on was this:

> [@Opening two .root file in the same canvas](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/16):
>
> These file contains Canvases not histrograms … You are mixing up many diferents things… root [0] TFile f("essai1\_2.root") root [1] f.ls() TFile\*\* essai1\_2.root TFile\* essai1\_2.root KEY: TCanvas Canvas 1;1 Canvas 1 root [2] TCanvas \*c = f.Get("Canvas 1"); root [3] c.Draw()

I have two files, ROC.root and SherpaRoc.root. They each contain Multiple TGraphs which show up in a TBrowser as Graph;1, Graph;2 … Graph;10. So I need to get Graph;10 from each file and plot them on the same graph (with different coloured lines). I’m not sure how to get Graph;10 rather than Graph;1, say, but then I can’t get it working at all yet.

I changed it back to “read” for the two existing files and get some weird output like this:

```auto
Processing combineROCCurves.C...

gdb.printing.register_pretty_printer(gdb.current_objfile(),

gdb.printing.register_pretty_printer(gdb.current_objfile(),

#0 0x00007f4b7708e41c in waitpid () from /lib64/libc.so.6

#1 0x00007f4b7700bf12 in do_system () from /lib64/libc.so.6

#2 0x00007f4b77bfe644 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.18

#3 0x00007f4b71fb8d95 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /usr/lib64/root/libCling.so

#4 0x00007f4b71fb823b in cling_runtime_internal_throwIfInvalidPointer () from /usr/lib64/root/libCling.so

#5 0x00007f4b7835819e in ?? ()

#6 0x00007fffb560b5d0 in ?? ()

#7 0x00007fffb560b5cf in ?? ()

#8 0x00007fffb560b5e0 in ?? ()

#9 0x0000000c00000000 in ?? ()

#10 0x0000000001bae8e0 in ?? ()

#11 0x0000000001b8f640 in ?? ()

#12 0x00000000019819a8 in ?? ()

#13 0x0000000001980ff8 in ?? ()

#14 0x0000000001a67cc0 in ?? ()

#15 0x0000000001981008 in ?? ()

#16 0x0000000001bae850 in ?? ()

#17 0x00007fffb560b830 in ?? ()

#18 0x0000000000000000 in ?? ()

Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments.

Execution of your code was aborted.

In file included from input_line_8:1:

**/home/atlas/krybacki/Pythia/Test/combineROCCurves.C:43:1:**  **warning:** **null passed to a callee that requires a non-null argument [-Wnonnull]**

graph->Draw();

```

which I’m guessing is it complaining that ‘graph’ doesn’t exist or something?

---

_[View the full topic](https://root-forum.cern.ch/t/plotting-two-tgraphs-from-a-different-root-file-on-the-same-graph/38786)._
