I now want to achieve surface drawing through TH2F and it has been successful, but the current color is drawn based on the content in SetBinContent. Can I set additional properties for each bin and then draw the color of the bin based on this property?
auto c2 = new TCanvas("c2", "c2", 600, 400);
auto hsurf3 = new TH2F("hsurf3", "Option SURF3 example ", 30, -4, 4, 30, -20, 20);
for (Int_t i = 0; i < 30; i++) {
for (Int_t j = 0; j < 30; j++) {
Int_t bin = hsurf3->GetBin(j + 1, i + 1);
hsurf3->SetBinContent(bin, i);
}
}
UInt_t Number = 2;
Double_t Red[2] = { 1.00, 0.00 };
Double_t Green[2] = { 0.00, 1.00 };
Double_t Blue[2] = { 0.00, 1.00 };
Double_t Length[2] = { 0.00, 1.00 };
Int_t nb = 50;
TColor::CreateGradientColorTable(Number, Length, Red, Green, Blue, nb);
hsurf3->SetContour(nb);
hsurf3->Draw("SURF1");
I don’t know how to define this plane. The diagram above was drawn by me using Matlab, but in fact, I only used the patch (X, Y, Z, C) function.
patch(X,Y,Z,C) creates the polygons in 3-D coordinates using X, Y, and Z. To view the polygons in a 3-D view, use the view(3) command. C determines the color.
In our root code, my idea is to add a C value similar to that in a patch (X, Y, Z, C) while setting the Z value for SetBinContent? If the C value is not set, draw the color according to the Z value. If the C value is set, draw the color according to the C value. This is my idea, I’m not sure if it’s feasible.
The patch technique from MathLab no… For the idea of drawing a 4th variable as color on SURF1 why not … but the question is: where is the 4th variable coming from ? … we can sider to draw te TH2 errors as colors. The option could be SURF1E
I just looked at the code for the ThistPainter and TPainter3dAlgorithms classes and found the following code in TPainter3dAlgorithms:: SurfaceFunction:
//The colors on the surface can represent the content or the errors
//If (fSumw2. fN) t [i]=gCurrentHist ->GetBinError (icx, iyt+iya);
//Else t [i]=f [i * 3+3];
T [i]=f [i * 3+3];
I feel that by releasing the code comments, it is possible to draw the color of surf1 according to error。Is my idea correct?