Non continuous / broken Xaxis

Hi,

Is there a way to draw a non-continuos x axis in TGraph?

For example I have
Double_t x1[5] = {1.,2.,3.,4.,5.}
Double_t x2[5] = {48.,49.,50.,51.,52}
Double_t y1[5] = {18.,9.,20.,21.,12}
TGraph *g1 = new TGraph(5,x1,y1);
TGraph g2 = new TGraph(5,x2,y1);
TMultiGraph mg = new TMultiGraph();
mg->Add(g1,"p
")
mg->Add(g2,"p
")
mg->Draw(“a”)

Now I would like the x axis to go from 1 to 5, then have the next number as 48, since there’s nothing between 5 and 48.

Is this possible?

Thanks in advance!

  • Sujeewa
{
   TCanvas *c = new TCanvas("c", "c",700,900);

   TPad *p1 = new TPad("p1","p1",0.1,0.5,0.9,0.901);
   p1->SetBottomMargin(0.);
   p1->SetFillColor(0);
   p1->SetBorderMode(0);
   p1->Draw();

   TPad *p2 = new TPad("p2","p2",0.1,0.1,0.9,0.501);
   p2->SetTopMargin(0.);
   p2->SetFillColor(0);
   p2->SetBorderMode(0);
   p2->Draw();

   float x1[] = {3,5,6,9}; float y1[] = {100,900,400,200};
   TGraph *gr1 = new TGraph(4,x1,y1);
   gr1->GetXaxis()->SetLimits(0.,10.);
   gr1->SetTitle("");
   gr1->GetXaxis()->SetLabelSize(0);
   gr1->GetXaxis()->SetTickLength(0);
   gr1->SetMarkerStyle(20);

   float x2[] = {1,2,3,8}; float y2[] = {4,7,6,5};
   TGraph *gr2 = new TGraph(4,x2,y2);
   gr2->GetXaxis()->SetLimits(0.,10.);
   gr2->SetTitle("");
   gr2->SetMarkerStyle(22);

   p1->cd();
   gr1->Draw("ALP");
   gr1->GetHistogram()->SetMinimum(-20.);

   p2->cd();
   gr2->Draw("ALP");
   gr2->GetHistogram()->SetMaximum(7.5);

   c->cd();
   TPad *b = new TPad("b","b",0.1,0.46,0.8199,0.53);
   b->SetBorderMode(0);
   b->SetFillColor(0);
   b->Draw();
   b->cd();
   TLine *line = new TLine(0.11,0,0.1105677,0.399656);
   line->Draw();
   line = new TLine(0.1105677,0.5860092,0.11,1);
   line->Draw();
   line = new TLine(0.076639,0.5143349,0.1524797,0.6863532);
   line->Draw();
   line = new TLine(0.076639,0.3423165,0.1524797,0.5143349);
   line->Draw();
}