hello, I have 5 txt file, I want to plots with Histogram option “HIST L” to the same Canvas, I tried to draw one after the other and when I do “same” in one Canvas with TBrowser I do not succeed to make two curve with option “HIST L” always it keeps the last curve with this option. so I want to try to trace them in the same code, can anyone help me?
this the code i used :
#include "Riostream.h"
void rt1()
{
TString dir = gSystem->UnixPathName(__FILE__);
dir.ReplaceAll("rt1.C","");
dir.ReplaceAll("/./","/");
ifstream in;
in.open(Form("%sNi.txt",dir.Data()));
Float_t x,y;
Int_t nlines = 0;
TFile *f = new TFile("profile.root","RECREATE");
TCanvas *c1 = new TCanvas("c1","c1",600,400);
TH1F *he = new TH1F("he"," with Histogram ",100,-150,150);
while (1) {
in >> x >> y;
if (!in.good()) break;
if (nlines < 800000) printf("x=%8f, y=%8f\n",x,y);
nlines++;
he->Fill(x,y);
}
gStyle->SetEndErrorSize(3);
gStyle->SetErrorX(1.);
he->SetMarkerStyle(20);
he->SetMarkerStyle(2);
he->SetMarkerColor(kBlue);
he->Draw("HIST L");
//ReverseYAxis(he);
f->Write();
return c1;
}
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
no, each file corresponding an energy, I want to plot them in a Canvas, the code above to trace from a one file.txt, so my question is how to read these files in same code to trace them like that:
it looks like you need to create a TGraph from a data frame as shown in the example above and then draw them together with the “Same” option specified.
We can tackle this in steps. Are you able to produce 5 graphs from the txt files?
D
To make sure the scales along the x and y axis will automatically contain all the TGraphs you will get from RDataFrame, you can also group them in a TMultiGraph and draw it (one single Draw).