{ // Dedomena Tash-Revma Kai peiramatika sfalnata double V[12]={1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0}; double I[12]={1.0, 2.0, 2.9, 4.0, 4.9, 5.9, 7.0, 8.0, 8.9, 10.0, 10.9, 11.9}; double sfalma_V[12]={0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3}; double sfalma_I[12]={0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2}; TGraphErrors *gr=new TGraphErrors(12,V,I,sfalma_V,sfalma_I); // Orismos toy grafimatos TF1 *f1 = new TF1("f1", "pol1", 0,15); // Orismos tis synartisis prosarmogis (polyonimo 1ou vathmou) gStyle->SetOptFit(111); // Extypwsi toy apotelesmatos tis prosarmogis c1=new TCanvas("c1", "Grafima", 1000, 800); c1->SetFillColor(42); c1->SetGrid(); gr->SetTitle ("Ohm's Law"); //Titlos grafimatos gr->GetXaxis()->SetTitle("V [Volts]"); //Monades ston x axona gr->GetYaxis()->SetTitle("I [mAmps]"); //Monacdes ston y axona gr->SetMarkerStyle(21) ; gr->SetMarkerSize(0.7); gr->SetMarkerColor(2) ; gr->SetLineColor(2) ; gr->Draw ("AP"); //Sxediasmos grafimatos gr->Fit(f1,"","",1,12); //Prosarmogi grafimatos }