ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
earth.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphics
3 /// This tutorial illustrates the special contour options.
4 ///
5 /// - "AITOFF" : Draw a contour via an AITOFF projection
6 /// - "MERCATOR" : Draw a contour via an Mercator projection
7 /// - "SINUSOIDAL" : Draw a contour via an Sinusoidal projection
8 /// - "PARABOLIC" : Draw a contour via an Parabolic projection
9 ///
10 /// \macro_image
11 /// \macro_code
12 ///
13 /// \author Olivier Couet (from an original macro sent by Ernst-Jan Buis)
14 
15 TCanvas *earth(){
16 
17  gStyle->SetPalette(1);
18  gStyle->SetOptTitle(1);
19  gStyle->SetOptStat(0);
20 
21  TCanvas *c1 = new TCanvas("c1","earth_projections",700,700);
22  c1->Divide(2,2);
23 
24  TH2F *ha = new TH2F("ha","Aitoff", 180, -180, 180, 179, -89.5, 89.5);
25  TH2F *hm = new TH2F("hm","Mercator", 180, -180, 180, 161, -80.5, 80.5);
26  TH2F *hs = new TH2F("hs","Sinusoidal",180, -180, 180, 181, -90.5, 90.5);
27  TH2F *hp = new TH2F("hp","Parabolic", 180, -180, 180, 181, -90.5, 90.5);
28 
29  TString dat = gSystem->UnixPathName(__FILE__);
30  dat.ReplaceAll(".C",".dat");
31  dat.ReplaceAll("/./","/");
32 
33  ifstream in;
34  in.open(dat.Data());
35  Float_t x,y;
36  while (1) {
37  in >> x >> y;
38  if (!in.good()) break;
39  ha->Fill(x,y, 1);
40  hm->Fill(x,y, 1);
41  hs->Fill(x,y, 1);
42  hp->Fill(x,y, 1);
43  }
44  in.close();
45 
46  c1->cd(1); ha->Draw("aitoff");
47  c1->cd(2); hm->Draw("mercator");
48  c1->cd(3); hs->Draw("sinusoidal");
49  c1->cd(4); hp->Draw("parabolic");
50 
51  return c1;
52 }
float Float_t
Definition: RtypesCore.h:53
TCanvas * c1
Definition: legend1.C:2
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
Basic string class.
Definition: TString.h:137
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1020
const char * Data() const
Definition: TString.h:349
Double_t x[n]
Definition: legend1.C:17
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
The Canvas class.
Definition: TCanvas.h:48
Double_t y[n]
Definition: legend1.C:17
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition: TPad.cxx:1073
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition: TStyle.cxx:1252
void SetOptTitle(Int_t tit=1)
Definition: TStyle.h:330
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:287
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445