| 36 |
//______________________________________________________________________________ |
//______________________________________________________________________________ |
| 37 |
/* Begin_Html |
/* Begin_Html |
| 38 |
<center><h2>TMultiGraph class</h2></center> |
<center><h2>TMultiGraph class</h2></center> |
| 39 |
A TMultiGraph is a collection of TGraph (or derived) objects |
|
| 40 |
Use <tt>TMultiGraph::Add</tt> to add a new graph to the list. |
A TMultiGraph is a collection of TGraph (or derived) objects. It allows to |
| 41 |
|
manipulate a set of graphs as a single entity. In particular, when drawn, |
| 42 |
|
the X and Y axis ranges are automatically computed such as all the graphs |
| 43 |
|
will be visible. |
| 44 |
|
<p> |
| 45 |
|
<tt>TMultiGraph::Add</tt> should be used to add a new graph to the list. |
| 46 |
|
<p> |
| 47 |
The TMultiGraph owns the objects in the list. |
The TMultiGraph owns the objects in the list. |
| 48 |
Drawing options are the same as for TGraph. |
<p> |
| 49 |
|
The drawing options are the same as for TGraph. |
| 50 |
|
Like for TGraph, the painting is performed thanks to the |
| 51 |
|
<a href="http://root.cern.ch/root/html/TGraphPainter.html">TGraphPainter</a> |
| 52 |
|
class. All details about the various painting options are given in |
| 53 |
|
<a href="http://root.cern.ch/root/html/TGraphPainter.html">this class</a>. |
| 54 |
<p> |
<p> |
| 55 |
Example: |
Example: |
| 56 |
<pre> |
<pre> |
| 61 |
mg->Add(gr2,"cp"); |
mg->Add(gr2,"cp"); |
| 62 |
mg->Draw("a"); |
mg->Draw("a"); |
| 63 |
</pre> |
</pre> |
| 64 |
|
<br> |
| 65 |
The drawing option for each TGraph may be specified as an optional |
The drawing option for each TGraph may be specified as an optional |
| 66 |
second argument of the Add function. |
second argument of the <tt>Add</tt> function. |
| 67 |
|
<p> |
| 68 |
If a draw option is specified, it will be used to draw the graph, |
If a draw option is specified, it will be used to draw the graph, |
| 69 |
otherwise the graph will be drawn with the option specified in |
otherwise the graph will be drawn with the option specified in |
| 70 |
<tt>TMultiGraph::Draw</tt>. |
<tt>TMultiGraph::Draw</tt>. |
| 71 |
|
<p> |
| 72 |
|
The following example shows how to fit a TMultiGraph. |
| 73 |
|
End_Html |
| 74 |
|
Begin_Macro(source) |
| 75 |
|
{ |
| 76 |
|
TCanvas *c1 = new TCanvas("c1","c1",600,400); |
| 77 |
|
|
| 78 |
|
Double_t x1[2] = {2.,4.}; |
| 79 |
|
Double_t dx1[2] = {0.1,0.1}; |
| 80 |
|
Double_t y1[2] = {2.1,4.0}; |
| 81 |
|
Double_t dy1[2] = {0.3,0.2}; |
| 82 |
|
|
| 83 |
|
Double_t x2[2] = {3.,5.}; |
| 84 |
|
Double_t dx2[2] = {0.1,0.1}; |
| 85 |
|
Double_t y2[2] = {3.2,4.8}; |
| 86 |
|
Double_t dy2[2] = {0.3,0.2}; |
| 87 |
|
|
| 88 |
|
gStyle->SetOptFit(0001); |
| 89 |
|
|
| 90 |
|
TGraphErrors *g1 = new TGraphErrors(2,x1,y1,dx1,dy1); |
| 91 |
|
g1->SetMarkerStyle(21); |
| 92 |
|
g1->SetMarkerColor(2); |
| 93 |
|
|
| 94 |
|
TGraphErrors *g2 = new TGraphErrors(2,x2,y2,dx2,dy2); |
| 95 |
|
g2->SetMarkerStyle(22); |
| 96 |
|
g2->SetMarkerColor(3); |
| 97 |
|
|
| 98 |
|
TMultiGraph *g = new TMultiGraph(); |
| 99 |
|
g->Add(g1); |
| 100 |
|
g->Add(g2); |
| 101 |
|
|
| 102 |
|
g->Draw("AP"); |
| 103 |
|
|
| 104 |
|
g->Fit("pol1","FQ"); |
| 105 |
|
return c1; |
| 106 |
|
} |
| 107 |
|
End_Macro |
| 108 |
|
Begin_Html |
| 109 |
|
<p> |
| 110 |
|
The axis titles can be modified the following way: |
| 111 |
|
<p> |
| 112 |
|
<pre> |
| 113 |
|
[...] |
| 114 |
|
TMultiGraph *mg = new TMultiGraph; |
| 115 |
|
mg->SetTitle("title;xaxis title; yaxis title"); |
| 116 |
|
mg->Add(g1); |
| 117 |
|
mg->Add(g2); |
| 118 |
|
mg->Draw("apl"); |
| 119 |
|
</pre> |
| 120 |
|
|
| 121 |
End_Html */ |
End_Html */ |
| 122 |
|
|
| 123 |
|
|