Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
earth.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// \notebook
4/// This tutorial illustrates the special contour options.
5///
6/// - "AITOFF" : Draw a contour via an AITOFF projection
7/// - "MERCATOR" : Draw a contour via an Mercator projection
8/// - "SINUSOIDAL" : Draw a contour via an Sinusoidal projection
9/// - "PARABOLIC" : Draw a contour via an Parabolic projection
10/// - "MOLLWEIDE" : Draw a contour via an Mollweide projection
11///
12/// \macro_image
13/// \macro_code
14///
15/// \author Olivier Couet (from an original macro sent by Ernst-Jan Buis)
16
17TCanvas *earth()
18{
19
22
23 TCanvas *c1 = new TCanvas("c1", "earth_projections", 700, 1000);
24 c1->Divide(2, 3);
25
26 TH2F *ha = new TH2F("ha", "Aitoff", 180, -180, 180, 179, -89.5, 89.5);
27 TH2F *hm = new TH2F("hm", "Mercator", 180, -180, 180, 161, -80.5, 80.5);
28 TH2F *hs = new TH2F("hs", "Sinusoidal", 180, -180, 180, 181, -90.5, 90.5);
29 TH2F *hp = new TH2F("hp", "Parabolic", 180, -180, 180, 181, -90.5, 90.5);
30 TH2F *hw = new TH2F("hw", "Mollweide", 180, -180, 180, 181, -90.5, 90.5);
31
32 TString dat = gROOT->GetTutorialDir();
33 dat.Append("/visualisation/graphics/earth.dat");
34 dat.ReplaceAll("/./", "/");
35
36 ifstream in;
37 in.open(dat.Data());
38 Float_t x, y;
39 while (1) {
40 in >> x >> y;
41 if (!in.good())
42 break;
43 ha->Fill(x, y, 1);
44 hm->Fill(x, y, 1);
45 hs->Fill(x, y, 1);
46 hp->Fill(x, y, 1);
47 hw->Fill(x, y, 1);
48 }
49 in.close();
50
51 c1->cd(1);
52 ha->Draw("aitoff");
53 c1->cd(2);
54 hm->Draw("mercator");
55 c1->cd(3);
56 hs->Draw("sinusoidal");
57 c1->cd(4);
58 hp->Draw("parabolic");
59 c1->cd(5);
60 hw->Draw("mollweide");
61
62 return c1;
63}
float Float_t
Definition RtypesCore.h:57
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:436
The Canvas class.
Definition TCanvas.h:23
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3068
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:308
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:393
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
TString & Append(const char *cs)
Definition TString.h:572
void SetOptTitle(Int_t tit=1)
Definition TStyle.h:334
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:1640
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17