Sandy  
                
               
                 
              
                  
                    November 7, 2019,  8:27am
                   
                   
              1 
               
             
            
              Hi,
I have this 3 column data filedata_test.txt  (274 Bytes) . I have plotted it using the following.
  TH3F *h3 = new TH3F("h3","3D",500,100,1000,500,500,1000,100,500,1000);
  for (unsigned i = 0; i < n; ++i) {
  in >> x >> y >> z;
  if (!in.good()) break;
  h3->Fill(x,y,z);
  }
  h3->Draw("cont4");
 
Now I want to have extrapolation and interpolation to get a smooth surface. Is there any way to do it?
 
Please read tips for efficient and successful posting  and posting code  
ROOT Version:  Not Provided 
Platform:  Not Provided 
Compiler:  Not Provided
 
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 7, 2019,  8:44am
                   
                   
              2 
               
             
            
              Have you tried the option ISO  ?
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 7, 2019,  8:51am
                   
                   
              3 
               
             
            
              Hi @couet , thanks.
No, I have not. 
You meant,… instead of  h3->Draw(“cont4”);, I should try h3->Draw(“GLISO”); ?
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 7, 2019,  8:56am
                   
                   
              5 
               
             
            
              And if I want to get a parametric equation out of it, then is there any option?
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 7, 2019,  9:07am
                   
                   
              6 
               
             
            
              That’s not Drawing . May be have a look at 3D histogram fitting.
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 7, 2019,  9:31am
                   
                   
              7 
               
             
            
              h3->Draw(“ISO”); is creating something like this...not a colored surface.!
 
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 7, 2019,  9:45am
                   
                   
              9 
               
             
            
              Yes, it is mono color. See the Help. 
Try GLISO (with SetCanvasPreferGL before. See Help) 
Also see if one of the examples here https://root.cern/doc/master/group__tutorial__gl.html  
matches what you are looking for.
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 10, 2019,  2:48pm
                   
                   
              10 
               
             
            
              I have tried with GLISO also, but, didn’t work.
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 11, 2019,  7:49am
                   
                   
              11 
               
             
            
              It might be there too less points to draw a surface through them using the available floating options. May be try to do a 3D fit.
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 12, 2019,  4:09pm
                   
                   
              12 
               
             
            
              Yeah, may be because of less data points…
But, how to do a 3D fit and get an equation back?
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 13, 2019, 12:41pm
                   
                   
              14 
               
             
            
              Thanks for the link. it is running. But, When I combine this with the one I posted at the beginning of this series, it does not show up in the plot and does not give the equation as well!
//file fit3.C
#include "TRandom3.h"
#include "Riostream.h"
#include <iostream>
#include "TH3.h"
#include "TF3.h"
#include "TMath.h"
   
double myfunc3(double *x, double *par) {
   double xx = (x[0] - par[1])/par[2];
   double yy = (x[1] - par[3])/par[4];
   double zz = (x[2] - par[5])/par[6];
   double rx = TMath::Exp(-xx*xx);
   double ry = TMath::Exp(-yy*yy);
   double rz = TMath::Exp(-zz*zz);
   double result = par[0]*rx*ry*rz;
   return result;
}
void fit3() {
   const unsigned nPts1 = 15; 
   ifstream in1;
   in1.open("data_test.txt");
   Float_t x1,y1,z1;
   TCanvas *c1 = new TCanvas("c1"," ",0,0,700,350);
   TH3F *h1 = new TH3F("h1","h1",100,1000,3000,100,0.5,1.0,100,0.0,1.0);
      for (unsigned i = 0; i < nPts1; ++i) {
      in1 >> x1 >> y1 >> z1;
      if (!in1.good()) break;
      h1->Fill(x1,y1,z1);
      }
   in1.close();
   c1->cd();
   TF3 *func3 = new TF3("func3",myfunc3,1000,3000,0.5,1.0,0.0,1.0,7);
   func3->SetParameters(h1->GetMaximum(),0,0.5,0,0.5,0,0.5);
   h1->Fit(func3,"r+","E");
   h1->Draw("col");
   func3->Draw("same");
   func3->SetLineColor(kOrange+8);
   func3->SetLineStyle(1);
   func3->SetLineWidth(2);
   h1->SetMarkerStyle(20);
   h1->SetMarkerSize(1.0);
   h1->SetMarkerColor(kBlue);
   c1->Update();
}
 
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 13, 2019, 12:54pm
                   
                   
              15 
               
             
            
              It gives me:
root [0] 
Processing fit3.C...
Warning in <Fit>: Fit data is empty 
 
do you get the same ?
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 13, 2019,  1:58pm
                   
                   
              16 
               
             
            
              I am not getting any fit.
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 13, 2019,  2:24pm
                   
                   
              17 
               
             
            
              I got that but when you run the macro do you also get the message:
Warning in <Fit>: Fit data is empty 
 
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 13, 2019,  3:20pm
                   
                   
              18 
               
             
            
              No…I am not getting that…
             
            
               
               
               
            
            
           
          
            
              
                couet  
                
               
              
                  
                    November 13, 2019,  3:30pm
                   
                   
              19 
               
             
            
              here is the macro and the data i am using. 
data_test.txt  (274 Bytes) fit3.C  (1.2 KB)
             
            
               
               
               
            
            
           
          
            
              
                Sandy  
                
               
              
                  
                    November 13, 2019,  4:02pm
                   
                   
              20 
               
             
            
              data_test.txt  (227 Bytes)
If you test with this one, may be you can run: [please make changes correspondingly like following]
TH3F *h1 = new TH3F(“h1”,“h1”,100,1000,3000,100,0.5,1.0,100,0.0,1.0);
… 
TF3 *func3 = new TF3(“func3”,myfunc3,1000,3000,0.5,1.0,0.0,1.0,7);