Re: options drawing multigraphs

From: Rene Brun <brun_at_pcroot.cern.ch>
Date: Tue, 12 Apr 2005 21:10:06 +0200 (MEST)


Mateusz,

The output you get is what I expect.
You never called tg1->Draw or tg2->Draw. So calling tg1->GetDrawOption or tg1->SetDrawOption does not make sense.

Rene Brun

On
Tue, 12 Apr 2005, Mateusz Ploskon
wrote:

> Thank You very much for Your answer...
> But if You could spend a second and execute this macro...
> In my case the only message which I see is:
> <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> and4 empty lines...
>
> {
> Float_t x[2] = {0, 1};
> Float_t y[2] = {1, 2};
> TGraph *tg1 = new TGraph(2, x, y);
> TGraph *tg2 = new TGraph(2, y, x);
>
> TMultiGraph *tgr = new TMultiGraph("tgr", "tgr");
> tgr->Add(tg1);
> tgr->Add(tg2);
>
> tgr->Draw("ALP");
>
> cout << tg1->GetDrawOption() << endl;
> cout << tg2->GetDrawOption() << endl;
>
> gPad->Update();
>
> tg1->SetDrawOption("F");
> tg2->SetDrawOption("F");
>
> cout << tg1->GetDrawOption() << endl;
> cout << tg2->GetDrawOption() << endl;
>
> }
>
> It seems that the gPad is set but the functions TGraph::Draw() are never
> called(?) How then the TMultiGraph paints the graphs(?)->(see below)
>
> I cannot change the DrawOptions for each of the TGraphs?
> This is my problem...:
>
> void TMultiGraph::Draw(Option_t *option)
> {
> //*-*-*-*-*-*-*-*-*-*-*Draw this multigraph with its current
> attributes*-*-*-*-*-*-*
> //*-* ==========================================
> //
> // Options to draw a graph are described in TGraph::PainGraph
> //
> // The drawing option for each TGraph may be specified as an optional
> // second argument of the Add function.
> // If a draw option is specified, it will be used to draw the graph,
> // otherwise the graph will be drawn with the option specified in
> // TMultiGraph::Draw
>
> AppendPad(option);
> }
>
> My best,
> Mateusz
>
> On Tuesday 12 April 2005 15:51, you wrote:
> > Hi Mateusz,
> >
> > before calling object.GetDrawOption, you must have called object.Draw.
> > See doc at
> > http://root.cern.ch/root/htmldoc/TObject.html#TObject:GetDrawOption
> > http://root.cern.ch/root/htmldoc/TObject.html#TObject:SetDrawOption
> >
> > For your point about finding the options in a list, see an example at
> > http://root.cern.ch/root/htmldoc/src/TObject.cxx.html#TObject:GetDrawOption
> >
> > Rene Brun
> >
> > On
> >
> > Tue, 12 Apr 2005, Mateusz Ploskon wrote:
> > > Please consider following:
> > >
> > > root [7] TH1F *alax = new TH1F("alax","alax", 12,10,111);
> > > root [8] alax->SetOption("la")
> > > root [9] alax->GetOption()
> > > (const Option_t* 0x90d16ec)"la"
> > > root [10] alax->SetDrawOption("la")
> > > root [11] alax->GetDrawOption()
> > > (const Option_t* 0xd0b416)""
> > >
> > > Actually, my question is how can I get the option of a TGraph which is
> > > owned by a TMultiGraph...
> > > What's wrong with the following code(?) for example:
> > >
> > > TMultiGraph *tmgr = new ....
> > > tmgr->Add(..., "L");
> > > ...
> > > TList *hlist = (TList*)tmgr->GetListOfGraphs();
> > > TIter *hiter = new TIter(hlist);
> > >
> > > TGraph *hist = 0;
> > > hiter->Reset();
> > > while ((hist = (TGraph*)hiter->Next()) != NULL)
> > > {
> > > cout << "Draw option?" << hist->GetTitle() << " " <<
> > > hist->GetDrawOption() << endl; // nothing... :(
> > > }
> > >
> > > On a side I have the impression that this option'ing stuff is a bit
> > > messy...
> > >
> > > my best!
> > > m.
> > >
> > > PS I've read the sources of TObject etc...
>
>
Received on Tue Apr 12 2005 - 21:19:27 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET