Histogram from txt FIle

Hello!

I have a two column of data: Energy and Flux. I am trying to draw histogram with energy in x-axis and flux in y-axis. However, I am not getting the desired result as I am only getting empty canvas. Here is my code:

{
        TFile *f = new TFile("data.root", "RECREATE");
        TNtuple *t= new TNtuple("Flux_data", "Data from DUNE", "Energy:Flux");
        t->ReadFile("data.txt");

        TH1F h("Flux_hist", "Energy vs. Flux; Energy; Flux", 25, 0, 50);
        t->Draw("Flux>>Flux_Hist");
        h.Write();
        f->Close();
}

May be try:

        auto h = TH1F("Flux_hist", "Energy vs. Flux; Energy; Flux", 25, 0, 50);
        t->Draw("Flux>>Flux_Hist");
        h->Write();

This is giving me Flux value in x-axis and frequency in y-axis. I want Energy value in x-axis and associated flux value in y-axis. Please let me know how I can do this. Thanks.

Try this: t->Draw("Flux:Energy"); // a TGraph
and / or that: t->Draw("Flux:Energy>>Flux_vs_Energy", "", "COLZ"); // a TH2F