# Confidence Levels in Root

**URL:** <https://root-forum.cern.ch/t/confidence-levels-in-root/31602>\
**Category:** Newbie\
**Created:** [November 15, 2018, 4:55am UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602 "2018-11-15T04:55:44Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 20, 2018, 4:29pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/21 "2018-11-20T16:29:46Z")

</div>

I am changing the range…then also it is not coming as in gnuplot : Range for test1.dat :  
“”  
TH2F \*hcont2 = new TH2F(“hcont2”," ",40,0,360,40,0,0.9);  
“”

---

<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:** [November 21, 2018, 1:21pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/22 "2018-11-21T13:21:12Z")

</div>

Well … it is hard to make a contour plot with a such histogram:

 ![22](https://root-forum.cern.ch/uploads/default/original/3X/6/e/6ecc4be76ca1bb6e11ebddbec8816e47f6696235.png)

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 1:36pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/23 "2018-11-21T13:36:35Z")

</div>

ohhkk… Now, I am trying a graph plot…  
By fixing z axis value… a graph between x and y axes.  
This is not working… Please see my updated folder  
[datafiles.tar.gz](https://root-forum.cern.ch/uploads/default/original/3X/4/4/44f2e556aa69e365dedeccaf9f61bd24d4a36064.gz) (1.5 KB)

Thank you.

---

<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:** [November 21, 2018, 2:38pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/24 "2018-11-21T14:38:43Z")

</div>

well a TGraph will simply connect the point (in order). I get the following picture using the option “al\*”

 ![11](https://root-forum.cern.ch/uploads/default/original/3X/2/1/217d9e443d1b53b907353af965e734301cee2348.jpeg)

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 2:51pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/25 "2018-11-21T14:51:05Z")

</div>

Yes, exactly I am also getting this. But if we use gnuplot with the script that I have updated in the folder it gives a different picture, I want to use ROOT for plotting this… Contours plots from ROOT.

---

<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:** [November 21, 2018, 2:56pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/26 "2018-11-21T14:56:58Z")

</div>

But look at the points you gave to TGraph … they are aligned on columns … nothing like a contour. As I said TGraph simply link the points by a line. if you want a contour your points should define it properly. I am curious to see the gnuplot script you are using with this data file and the kind of plot you get.

---

<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:** [November 21, 2018, 3:04pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/27 "2018-11-21T15:04:58Z")

</div>

I tried your commands in gnuplot. But it does not work for me.

```auto
gnuplot> set contour
gnuplot> set view map
gnuplot> unset surface
gnuplot> set cntrparam discrete levels 2.3,6.2,11.8
                       ^
         expecting 'linear', 'cubicspline', 'bspline', 'points', 'levels' or 'order'

gnuplot> splot "test1.dat" with lines
WARNING: Plotting with an 'unknown' terminal.
No output will be generated. Please select a terminal with 'set terminal'.
gnuplot> 

```

---

<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:** [November 21, 2018, 3:13pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/28 "2018-11-21T15:13:55Z")

</div>

```auto
{
  TGraph2D *g1 = new TGraph2D("test1.dat");
  g1->SetNameTitle("g1", "test1;x;y;z");
  TGraph2D *g2 = new TGraph2D("test2.dat");
  g2->SetNameTitle("g2", "test2;x;y;z");
  Double_t c3[3] = {2.3, 6.2, 11.8};
  TCanvas *c = new TCanvas("c", "c", 800, 400);
  c->Divide(2, 1);
  c->cd(1);
  g1->Draw("SURF3"); // e.g. "SURF3" or "CONT5"
  g1->GetHistogram()->SetContour(3, c3);
  c->cd(2);
  g2->Draw("SURF3"); // e.g. "SURF3" or "CONT5"
  g2->GetHistogram()->SetContour(3, c3);
  c->cd(0);
}

```

---

<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:** [November 21, 2018, 3:17pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/29 "2018-11-21T15:17:06Z")

</div>

Yes or

```auto
g->Draw("CONT1");

```

which gives:

 ![10](https://root-forum.cern.ch/uploads/default/original/3X/b/2/b269b27062545b45e2248ad47f19cd734df0fd72.jpeg)

But i am not sure that’s what @srishino wants as he tried tor Draw the contour directly for the dat file … that might suggest that the data in the dat file are defining the contour.

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 3:38pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/30 "2018-11-21T15:38:32Z")

</div>

Hi,  
This is the plot that I am getting using the script below-  
“”  
gnuplot\> set contour  
gnuplot\> set view map  
gnuplot\> unset surface  
gnuplot\>set cntrparam levels discrete 2.3,6.2,11.8  
gnuplot\> splot [0:360][0:0.9] “test1.dat” with lines  
“”

[mygnuplot.pdf](https://root-forum.cern.ch/uploads/default/original/3X/d/2/d200398e2897425cff998bd7f3aad36be227536f.pdf) (7.7 KB)

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 3:39pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/31 "2018-11-21T15:39:30Z")

</div>

These are the details of GNUPLOT version that I am using-

```
G N U P L O T
Version 4.6 patchlevel 2 last modified 2013-03-14 
Build System: Linux x86_64
```

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 3:53pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/34 "2018-11-21T15:53:49Z")

</div>

gnuplot\> set terminal pdf

---

<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:** [November 21, 2018, 3:57pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/35 "2018-11-21T15:57:15Z")

</div>

have you tried Wile suggestion ?

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 4:11pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/36 "2018-11-21T16:11:59Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> ```auto
> {
> TGraph2D *g1 = new TGraph2D("test1.dat");
> g1->SetNameTitle("g1", "test1;x;y;z");
> TGraph2D *g2 = new TGraph2D("test2.dat");
> g2->SetNameTitle("g2", "test2;x;y;z");
> Double_t c3[3] = {2.3, 6.2, 11.8};
> TCanvas *c = new TCanvas("c", "c", 800, 400);
> c->Divide(2, 1);
> c->cd(1);
> g1->Draw("SURF3");
> g1->GetHistogram()->SetContour(3, c3);
> c->cd(2);
> g2->Draw("SURF3");
> g2->GetHistogram()->SetContour(3, c3);
> c->cd(0);
> }
> 
> ```

I just tried this… I am getting the plot attached below-

[myRootplot.pdf](https://root-forum.cern.ch/uploads/default/original/3X/7/8/789da9a6b351caabe8a5c68b64cc403b996dafd4.pdf) (117.1 KB)

I want only the red portion as a one-dimensional plot…

---

<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:** [November 21, 2018, 4:21pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/37 "2018-11-21T16:21:11Z")

</div>

[Instead of “SURF3”, try “CONT5”, …, “CONT0”.](https://root.cern.ch/doc/master/classTHistPainter.html#HP01c)

---

<div class="post-metadata">

**Author:** ![srishino](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@srishino](https://root-forum.cern.ch/u/srishino)\
**Post date:** [November 21, 2018, 4:48pm UTC](https://root-forum.cern.ch/t/confidence-levels-in-root/31602/38 "2018-11-21T16:48:18Z")

</div>

Yea its working… Thanks a lot… 🙂

[Previous page](https://root-forum.cern.ch/t/confidence-levels-in-root/31602.md?page=1)
