# TMultiGraph GetMax(Min)imum

**URL:** <https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127>\
**Category:** ROOT\
**Tags:** hist\
**Created:** [September 5, 2017, 9:36pm UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127 "2017-09-05T21:36:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 5, 2017, 9:36pm UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/1 "2017-09-05T21:36:08Z")

</div>

Hi,

Is there any way currently (6.10.04) to get the Maximum or minimum value for a `TMultiGraph`? I see methods for setting, but not for getting.

Thanks

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 5, 2017, 10:26pm UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/2 "2017-09-05T22:26:41Z")

</div>

I attempted to add Getter methods, but they always return `-1111`

```auto
virtual Double_t GetMaximum() const {return fMaximum;}
virtual Double_t GetMinimum() const {return fMinimum;}

```

For that matter, even `TGraph` which already has the methods responds the same way:

```auto
{
   const int n = 3;
   const double x[n] = {5.5, 6.7, 9.8};
   const double y[n] = {34.4, 56.8, 12.3};
   TGraph g(n,x,y);

   std::cout << g.GetMinimum() << " " << g.GetMaximum() << "\n";
   g.Draw();
   std::cout << g.GetMinimum() << " " << g.GetMaximum() << "\n";
}

```

```auto
$ root test.C 
root [0] 
Processing test.C...
-1111 -1111
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
-1111 -1111
root [1]

```

---

<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:** [September 6, 2017, 7:50am UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/3 "2017-09-06T07:50:56Z")

</div>

what about:

```auto
g->GetHistogram()->GetMaximum();

```

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 6, 2017, 6:31pm UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/4 "2017-09-06T18:31:56Z")

</div>

Ahh, yes that meets my needs. It does leave the question of what `TGraph::SetMaximum` purpose is?

---

<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:** [September 8, 2017, 6:43am UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/5 "2017-09-08T06:43:01Z")

</div>

It is a shortcut to

```auto
GetHistogram()->SetMaximum().;

```

See the code here:  
[https://root.cern/doc/master/TGraph\_8cxx\_source.html#l02138](https://root.cern/doc/master/TGraph_8cxx_source.html#l02138)

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 8, 2017, 2:42pm UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/6 "2017-09-08T14:42:49Z")

</div>

Ok, that narrows it down to why is `GetMaximum()` not a shortcut? I see that `SetMaximum()` sets `fMaximum`, but that this value is not set anywhere else, why do we need `fMaximum` at all if the value is stored in the histogram?. Calling `GetMaximum()` without ever calling `SetMaximum()` only returns the default `-1111` value, since the `fMaximum` value is not set from the histogram. I would go ahead and change this, but it is not clear to me what the intended behavior is.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [September 25, 2017, 8:40am UTC](https://root-forum.cern.ch/t/tmultigraph-getmax-min-imum/26127/8 "2017-09-25T08:40:24Z")

</div>

Closed on September 25, 2017, 8:40am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
