Re: options drawing multigraphs

From: Rene Brun <brun_at_pcroot.cern.ch>
Date: Thu, 14 Apr 2005 09:04:23 +0200 (MEST)


GetDrawOption should only be called on a object for which you did graph.Draw in the current pad.

To make easier the access to the option specified in TMultiGraph::Add I have added a new member function GetGraphDrawOption. Now in CVS. see:
http://root.cern.ch/root/htmldoc/TMultiGraph.html#TMultiGraph:Draw http://root.cern.ch/root/htmldoc/src/TMultiGraph.cxx.html#TMultiGraph:GetGraphDr awOption

You can look at the code in this function to adapt it to your case in case you cannot use the CVS version.

Rene Brun

On
Wed, 13 Apr
2005, Mateusz Ploskon wrote:

> Dear Rene,
>
> By this example I wanted only to suggest/ask if there would be a possibility
> to iterate on the list of graphs of a multi-graph and internally there add
> the graph to the gPad or whatever makes the draw option usable... e.g. then
> one would not have to call the ::Draw() for each of the graphs... If that is
> not possible... nevermind.
>
> My best,
> m.
>
> On Tuesday 12 April 2005 21:10, you wrote:
> > 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:GetDrawOp
> > > >tion
> > > >
> > > > 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 Thu Apr 14 2005 - 09:04:29 MEST

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