Re: Multi Color Graph

Rene Brun (Rene.Brun@cern.ch)
Tue, 28 Oct 1997 11:27:45 +0100


ROHLFS Reiner wrote:
>
> Hi Rooters,
>
> I want to draw a graph, but the color of the line should change if the Y-value
> is above or below a limit.
>
> I created a
> class LimitGraph : public TGraph
> {
> public:
> virtual void PaintGraph(Int_t npoints, Float_t *x, Float *y, Option_t *chopt);
> };
>
> In case of chopt == "L" this LimitGraph::PaintGraph() functions draws the line
> itself. For the other options TGraph::PaintGraph() is called.
>
> Inside this LimitGraph::PaintGraph() function the full line is split into parts
> where the color should not change (the line does not pass a Y-limit) For each
> part I call
>
> SetLineColor(col);
> gPad->PaintPolyLine(nrPt, xwork, ywork);
>
> where col is the color the line should have,
> nrPt is the number of points of the part of line and
> xwork, ywork are arrays of the points of the line.
>
> But the color of the line does not change!
> How can I set the color for each part of the line?
>

Instead of the two statements above, do:
SetLineColor(col);
TAttLine::Modify();
gPad->PaintPolyLine(nrPt, xwork, ywork);

Rene Brun