#include "TCanvas.h" #include "TH1.h" #include "TGraph.h" #include "TAxis.h" #include "TGaxis.h" //This program reads data from the table2.txt file and plot the fourth and sixth colomn as x and y void ReverseYAxis (TH1 *h); void Astro () { TGraph *g = new TGraph("/Users/kumakenkoji/Desktop/table3.txt", "%*s %*s %*s %lg %*s %lg"); TCanvas *c1 = new TCanvas ("c1", "canvas1", 200,10,600,400); g->GetYaxis()->SetTitle("V mag"); g->GetXaxis()->SetTitle("B-V"); g-> Draw("A*"); ReverseYAxis(g); } // reverse Yaxis void ReverseYAxis (TH1 *h) { //Remove the current axis h->GetYaxis()->SetLabelOffset(999); h->GetYaxis()->SetTickLength(0); //Redraw the new axis gPad->Update(); TGaxis *newaxis = new TGaxis(gPad->GetUxmin(), gPad->GetUymax(), gPad->GetUxmin()-0.001, gPad->GetUymin(), h->GetYaxis()->GetXmin(), h->GetYaxis()->GetXmax(), 510,"+"); newaxis->SetLabelOffset(-0.03); newaxis->Draw(); }