Hi Judith,
You should use the statements:
gPad->Modified();
gPad->Update();
to force the update of a pad/canvas inside a macro. We have several
examples
in the tutorials.
See also: http://root.cern.ch/root/HowtoDraw.html
When you want to draw the same object in two different states in the
same
or different pads, use DrawCopy instead of Draw.
See for example: http://root.cern.ch/root/html/examples/h1draw.C.html
Rene Brun
Judith Katzy wrote:
>
> Hello rooters,
>
> during an analysis loop, I want to fill one histogram, draw it, reset
> it and fill it with a different value, draw it again. It works fine,
> if I do it on the command line, but if I try to do it in a macro, it
> draws the histogram with the last value in all of the pads. See macro
> below.
> This behaviour occurs, because TH1::Draw() only attaches a reference to
> the pad. According to the documentation, the effective drawing is
> performed when the canvas receives a signal to be painted, which is after
> a carriage return, in this case at the end of the macro.
> Is there a way to invoke the drawing of the pad before that?
>
> Another effect is, that if the histogram is drawn with different values
> in different pads and one invokes TCanvas::Print() all histograms are
> replaced with the histogram containing the latest value.
>
> Is there a way to work with just one histogram?
>
> cheers,
> Judith
>
> {
>
> TCanvas *cw;
> if(!cw) cw = new TCanvas("test","test",700,700);
> cw->Clear();
> cw->Divide(1,2);
> TH1D ht("ht","ht",4,0.,3.);
>
> cw->cd(1);
> ht.Fill(0.);
> ht.Draw();
>
> cw->cd(2);
> ht.Reset();
> ht.Fill(2.);
> ht.Draw();
> }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:39 MET