#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 (TGraph *g); void Astro () { //TGraph *g = new TGraph("/Users/kumakenkoji/Desktop/table3.txt", "%*s %*s %*s %lg %*s %lg"); // Fake graph because I do not have /Users/kumakenkoji/Desktop/table3.txt TGraph *g = new TGraph(); g->SetPoint(1,2.,3.); g->SetPoint(2,20.,30.); g->SetPoint(3,200.,300.); 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 (TGraph *g) { //Remove the current axis g->GetYaxis()->SetLabelOffset(999); g->GetYaxis()->SetTickLength(0); //Redraw the new axis gPad->Update(); TGaxis *newaxis = new TGaxis(gPad->GetUxmin(), gPad->GetUymax(), gPad->GetUxmin()-0.001, gPad->GetUymin(), g->GetYaxis()->GetXmin(), g->GetYaxis()->GetXmax(), 510,"+"); newaxis->SetLabelOffset(-0.03); newaxis->Draw(); }