Dear ROOT experts,
I would like to draw a scatter plot. Unfortunately, I do not have access to root v6.30 and TScatter
. Following the discussions on blog, I would like to try TTree::Draw
with option "COLZ"
.
After reading document, I got confused. It is said given e1:e2:e3
, a TPolyMarker3D
is drawn. However, it is said a TH3F
object can be retrieved with three variables. I try to understand things from the source code in TTreePlayer::DrawSelect
. I do not see the explicit creation of TPolyMarker3D
.
I also tried to manipulate a toy example. It shows me the histogram is filled and the maximum and minimum are those of z components.
I do not want to bin data points to TH3F
which is subject to bin width and reduce granularity. I would like to have a series of discrete points like TGraph2D
but in flat view. I have no idea of use by TH3F
here.
I have several questions in mind.
- What is the use for
TH3F
here? Is it only for frame drawing? Is it also for data storage? Will the data points be binned to a histogram? - What can I do to set marker properties? I tried
hist->SetMarkerSize
but it seems not working. - What is the use of
TH1::GetListOfFunctions
. I found aTObjArray
calledgraphs
after printing it out. What are object and class saved in this array? I tried to callTObject::Print
by dereferencing each object and it returns me a (x, y) pair. - If I would like to create a
TPolyMarker3D
, how can I draw it in a flat view likeTH2::Draw("COLZ")
?
A test macro is also attached here.
#include <iostream>
#include "TNtuple.h"
#include "TCanvas.h"
#include "TH2F.h"
#include "TH3F.h"
void test ()
{
TNtuple t("t", "", "x:y:z");
float a[3];
for (int i=0; i<100; ++i) {
a[0] = i;
a[1] = 2*i+1;
a[2] = i+2;
t.Fill(a);
}
TCanvas* c = new TCanvas;
t.Draw("x:y:z", "", "COLZ");
auto htemp = (TH3F*)c->FindObject("htemp");
std::cout << htemp->GetXaxis()->GetNbins() << std::endl;;
std::cout << htemp->GetYaxis()->GetNbins() << std::endl;;
std::cout << htemp->GetZaxis()->GetNbins() << std::endl;;
std::cout << htemp->GetEntries() << std::endl;;
//htemp->Print("all");
gPad->Modified();
gPad->Update();
std::cout << "Maximum " << htemp->GetMaximum() << "\n";
std::cout << "Minimum " << htemp->GetMinimum() << "\n";
htemp->GetListOfFunctions()->Print("");
// auto objs = (TObjArray*)htemp->GetListOfFunctions()->FindObject("graphs");
// for (int i=0; i<objs->GetSize(); ++i) {
// auto ptr = objs->At(i);
// if (ptr) {
// ptr->Print();
// std::cout << ptr->GetName() << "\n";
// }
// }
//
}
Many thanks in advance!
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.28
Platform: Debian x86_64
Compiler: gcc 12