In some of my plots I want to show an excluded area by just
shading it in gray. To this end I tried the following
----------------------------------------------------------------------
TH2F *Shade = new TH2F("excl", "", xbins, xmin, xmax, ybins, ymin, ymax);
for( Double_t x = xmin; x < xmax; x += (xmax-xmin)/xbins) {
for(Double_t y = ymin; y < ymax; y += (ymax-ymin)/ybins) {
val = curve(y, x);
if (val <= excl) {
Shade->SetBinContent(
Shade->FindBin(x,y), 500);
}
else {
Shade->SetBinContent(
Shade->FindBin(x,y), 0);
}
}
}
Double_t contours[1];
contours[0] = excl;
Shade->SetContour(1, contours);
Shade->Draw("cont4");
----------------------------------------------------------------------
Now, unfortunately root fills the area _above_ the curve in
black (I did not even find how to change that colour) and
not the one below. I always get it displayed in white,
wheras I'd like something like gray70. Actually the area
above the curve should be transparent so that I could
Draw("cont4,same"), above another graph. Searching arround
did not give me a clue (though I came accros some other
interesting things ;)
Does anybody have a hint how to do this?
Many thanks in advance!
(Running root 5.10/00 @debian sarge.)
--
Kind regards, / War is Peace.
| Freedom is Slavery.
Alexander Wagner | Ignorance is Strength.
|
| Theory : G. Orwell, "1984"
/ In practice: USA, since 2001
I have recently implemented this in TGraph. See
$ROOTSYS/tutorials/graphpolar.C
This has been introduced in the last ROOT release. See:
http://root.cern.ch/root/Version511.news.html
Cheers, Olivier Couet
Hi!
> I have recently implemented this in TGraph. See
> $ROOTSYS/tutorials/graphpolar.C
> This has been introduced in the last ROOT release. See:
> http://root.cern.ch/root/Version511.news.html
Just finished compiling it and tried your example. But I do
not see how to use it in my case. My problem is, that I have
something like z=f(x,y) and the area that I want to shade is
"everything below z=excl". Additionally I can not easily
solve f(x,y) for x or y analytically. That's why I used a
TH2F to raster the area. Did I miss something? Maybe there
is a way to extract the proper contour line easily into
arrays so I can fill it into a TGraph? Did I miss that?
Thanks in advance!
I suggested this approach because the description you made seemed close
to this new functionality, but it may well be that you need something
else. Can you send me a small *running* example showing what you do ?
Thanks, O.Couet
--
Org: CERN - European Laboratory for Particle Physics.
Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
E-Mail: Olivie...@cern.ch Phone: +41 22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7670300
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)
O.Couet
On Thu, 8 Jun 2006,
Alexander Wagner wrote:
> On Thu, Jun 08, 2006 at 10:49:31AM +0200, Olivier Couet wrote:
>
> Hi!
>
> > I suggested this approach because the description you made seemed close
> > to this new functionality,
>
> Yes. That's why I started compiling. ;)
>
> > but it may well be that you need something else. Can you
> > send me a small *running* example showing what you do ?
>
> Included. It's modeled exactly like my script, I just
> simplified the Function and droped cosmetics. If you execute
> it you'll see "the inverse" of what I'd need. That is the
> lower left corner is clear whereas the upper right is filled
> in black.
>
> > > > I have recently implemented this in TGraph. See
> > > > $ROOTSYS/tutorials/graphpolar.C
> > > > This has been introduced in the last ROOT release. See:
> > > > http://root.cern.ch/root/Version511.news.html
> > >
> > > Just finished compiling it and tried your example. But I do
> > > not see how to use it in my case. My problem is, that I have
> > > something like z=f(x,y) and the area that I want to shade is
> > > "everything below z=excl". Additionally I can not easily
> > > solve f(x,y) for x or y analytically. That's why I used a
> > > TH2F to raster the area. Did I miss something? Maybe there
> > > is a way to extract the proper contour line easily into
> > > arrays so I can fill it into a TGraph? Did I miss that?
> > >
> > > Thanks in advance!
>
>
--
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!
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.
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.
--
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?