# Re: Filling area under a curve

From: Alexander Wagner <a.wagner_at_physik.uni-wuerzburg.de>
Date: Thu, 8 Jun 2006 20:41:35 +0200

On Thu, Jun 08, 2006 at 02:09:32PM +0200, Olivier Couet wrote:
>
>
>
>
> On Thu, 8 Jun 2006, Alexander Wagner wrote:
>
> > On Thu, Jun 08, 2006 at 12:19:52PM +0200, Alexander Wagner wrote:
> >
> > Hi!
> >
> > > > The low let part is left empty. The upper part of the contour is drawn
> > > > (to draw a filled contour you need two contours at least). A simple way to
> > > > obtain what you need is to "invert" your function. Instead of returning
> > > > "z" return (xmax*xmax+ymax*ymax-z) and instead of drawing the level "excl"
> > > > draw the level (xmax*xmax+ymax*ymax-excl)
> > >
> > > Sometimes it can be so simple, that one doesn't see it
> > > anymore. Thanks very much!
> >
> > Sorry again, but it has a drawback I found now that I was
> > composing my graphs. This exclusion area is meant to be
> > layed on top of another graph, but unfortunately root fills
> > the upper part in white rather than leaving it transparent.
> > So I get the exclusion area once I lay it on top of the data
> > the latter is covered. :( So this does not work out yet. If
> > you have an idea how that could be accomplished I'd be
> > thankful.
>
> Rather than using an histogram to draw this area, I think a Filled Smooth
> TGraph or a simple Polygon would be simpler.

Ok, I was able to come up with a solution based on this, but the filling behaves a bit strange. First of all I need something like

TGraph2D *gr1 = new TGraph2D();
TGraph *Excluded = new TGraph();

// fill in the data
gr1 = plot3d(file, xcol,ycol,zcol, cols);    Excluded = GetExcludedArea();

// Get the coordinate system from the TGraph()    Excluded->Draw("AFL");

// plot the actual data, but this lies above the excluded    // region...
gr1->Draw("cont1,same");

// draw the excluded region again to cover the data there    Excluded->Draw("FL,same");

Now if I zoom the graph in either x or y axis at some point root connects the last point of the TGraph drawn with the first point of the TGraph drawn and fills the resulting polygon what is surely not what I want. E.g. take something like

y^

```   |
_|____
a |cccc|
|cccc|
|cccc|
|cccc|
|ccccc\_______
|ccccccccccccc|
-|----------------->x

```

Now if I zoom y below the value "a" root connects diagonally and fills with the colour:

```      what I get:                 what I (still) want:
y^                            y^____
|    |\                       |cccc|
|    |cc\                     |cccc|
|    |cccc\                   |cccc|
|    |cccccc\                 |cccc|
|     \_______\               |ccccc\_______
|                             |ccccccccccccc|
-|----------------->x         -|----------------->x

```

I think root has here a problem with the fill function.

Any hints for this problem?

```--

Kind regards,                /                 War is Peace.
|            Freedom is Slavery.
Alexander Wagner            |         Ignorance is Strength.
|
| Theory     : G. Orwell, "1984"
/  In practice:   USA, since 2001
```
Received on Thu Jun 08 2006 - 20:39:45 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:59 MET