Hi all,
I need to produce a TGraph2D where:
- x axis is a time scale;
- y axis the name of identification of my detectors;
- z axis a float (for instance the noise of a detector in a precise time).
I produced the following function in my program:
TCanvas* makeplot2D(const std::map<std::string,std::vector<std::pair<int,float> > >& maskV_perRoll)
{
TDatime offset(2008,05,04,23,59,55);int T0=offset.Convert(0);
TCanvas *c = new TCanvas(“c”,“Graph2D example”);
TGraph2D *dt = new TGraph2D();
dt->SetNameTitle(“Summary”,“Summary”);
std::vectorstd::string st;
int roll(0); int roll1(0);
std::map<std::string,std::vector<std::pair<int,float> > >::const_iterator maskIt;
for(maskIt=maskV_perRoll.begin();maskIt!=maskV_perRoll.end();maskIt++){
std::vector<std::pair<int,float> >::const_iterator vIt=(maskIt->second).begin();
Int_t k(0);
for(;vIt!=(maskIt->second).end();vIt++, k++){
dt->SetPoint(roll,vIt->first-T0,roll1,vIt->second);
roll++;
}
st.push_back(maskIt->first);
roll1++;
}
for(unsigned j = 1; j <= st.size(); ++j )
dt->GetYaxis()->SetBinLabel(j, (st[j-1]).c_str());
dt->GetXaxis()->SetTimeDisplay(1);
dt->GetXaxis()->SetTimeFormat("%d/%m");
dt->GetXaxis()->SetLabelOffset(0.03);
dt->GetXaxis()->SetLabelFont(32);
dt->GetXaxis()->SetLabelOffset(0.03);
dt->GetXaxis()->SetTitleFont(32);
dt->GetYaxis()->SetTitleOffset(0.06);
dt->GetYaxis()->SetLabelFont(32);
dt->GetYaxis()->SetTitleFont(32);
gStyle->SetPalette(1);
dt->Draw(“PCol”);
dt->GetXaxis()->SetTimeDisplay(1);
c->Update();
return c;
}
maskV_perRoll is a map between a string (which is the name of the detector) and vector of pair where are stored time and noise respectively.
What I want is a bi-dimensional plot (x,y) where the z is represented by a color. (I would like avoid plot such as “surf1” or “cont” type).
Unlucky the results is just one of mentioned plot where I am not able neither to set the label I want on the Yaxix and the time unit in the Xaxis.
Please, could somebody tell me how to achieve my goal?
Thanks in advance
Raffaello