#include "TCanvas.h" #include "TPad.h" #include "TMultiGraph.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TAxis.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "TPaveStats.h" #include "TStyle.h" #include void RC() { const char *datain = "C:/data2.txt"; const char *dataout = "C:/simulazione/RC.pdf"; TCanvas *c01 = new TCanvas("c01","Graph",1280,1024); float offx=1.3; float offy=1.3; float margr=0.08; float w=3; float margl=0.12; float line=2; gPad->SetLeftMargin(margl); gPad->SetRightMargin(margr); TGraph *graph = new TGraph(datain,"%lg %lg"); graph->SetMarkerColor(kBlue); graph->SetLineColor(kBlue); graph->SetMarkerStyle(3); graph->SetMarkerSize(1.3); graph->SetLineWidth(line); TPaveText *t=new TPaveText(0.7,0.15,0.75,0.2,"brNDC"); graph->Draw("ap"); graph->SetTitle("RC circuit"); graph->GetXaxis()->SetTitle("Time (s)"); graph->GetYaxis()->SetTitle("Voltage (V)"); graph->GetYaxis()->SetTitleOffset(offy); graph->GetXaxis()->SetTitleOffset(offx); TLegend* leg = new TLegend(0.15, 0.75, .25, .85); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(graph, "Data", "ap"); leg->Draw(); gPad->Update(); TPaveStats *stat = (TPaveStats*)(graph->FindObject("stats")); stat->SetTextColor(kRed+2); stat->SetX1NDC(0.85); stat->SetX2NDC(0.98); stat->SetY1NDC(0.79); stat->SetY2NDC(0.94); gPad->Update(); gPad->Update(); c01->Print(dataout); }