Hi all,
I am quite new in root. I have a data set containing x,y,z and count. Now I want to plot this data with color scale (I am getting scatter plot with black points which looks pretty boring!!). But I am unable to do it presently. For your convenience I am giving you one example what I want. If you have any idea of making it even beatiful looking please suggest.
Why is this not in the documentation? According to that we can only draw it as (black and white) scatter plot or different variants of box plots. A colored scatterplot is not mentioned:
Option Description
" " Default (scatter plot).
"ISO" Draw a Gouraud shaded 3d iso surface through a 3d histogram. It paints one surface at the value computed as follow: SumOfWeights/(NbinsX*NbinsY*NbinsZ).
"BOX" Draw a for each cell with volume proportional to the content's absolute value. An hidden line removal algorithm is used
"BOX1" Same as BOX but an hidden surface removal algorithm is used
"BOX2" The boxes' colors are picked in the current palette according to the bins' contents
"BOX2Z" Same as "BOX2". In addition the color palette is also drawn.
"BOX3" Same as BOX1, but the border lines of each lego-bar are not drawn.
"LEGO" Same as BOX.
Well, you have 4 variables with a TH3?, x, y, z, count. Note that there is an option to draw boxes which are colored according to the bin content ("BOX2"), just not to draw a scatter plot with the same.
Hi all,
Two more questions. Now was trying to plot my data.
There are two problems:
1. I can not set the minimum count in the color bar. Where I don’t have data still I get ‘sky blue’ color.
2. I can not write the axis title in X-axis. And Z-axis title comes in two places, along Z-axis and along color bar as shown in the figure.
I am using the lines below.
ntuple->Draw(“x:y:z:cont>>plot4d”,"",“COLZ”);
plot4d->GetXaxis()->SetTitle(“X (mm)”);
plot4d->GetYaxis()->SetTitle(“Y (mm)”);
plot4d->GetZaxis()->SetTitle(“Z (mm)”);
plot4d->GetXaxis()->SetTitleOffset(1.5);
plot4d->GetYaxis()->SetTitleOffset(1.8);
plot4d->GetZaxis()->SetTitleOffset(1.5);
plot4d->GetXaxis()->CenterTitle(true);
plot4d->GetYaxis()->CenterTitle(true);
plot4d->GetZaxis()->CenterTitle(true);
plot4d->SetMinimum(3.);
Please suggest. Thanks in advance
Hi Olivier,
I am attaching the code I am using right now. Now I have able to remove the ‘sky-blue’ (where the count is zero) by putting a condition while writing the ntuple (if(count>0)). But of course I am still not able to vary the limit of the color scale.
Secondly, I found there is an additional problem. When I am creating the plot from ntuple it looks like some modification is happening due to binning. I am attaching both the plots for your convenience. Please suggests.
Regards,
Arnab
$ root basic.C
-----------------------------------------------------------------
| Welcome to ROOT 6.11/01 http://root.cern.ch |
| (c) 1995-2017, The ROOT Team |
| Built for macosx64 |
| From heads/master@v6-09-02-2768-g3348aeb, Sep 29 2017, 17:54:00 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
-----------------------------------------------------------------
root [0]
Processing basic.C...
In file included from input_line_14:1:
/Users/couet/roottest/basic.C:86:4: error: use of undeclared identifier 'plot4d'
plot4d->GetXaxis()->SetTitle("X-Momentum (au)");
^
/Users/couet/roottest/basic.C:87:4: error: use of undeclared identifier 'plot4d'
plot4d->GetYaxis()->SetTitle("Y-Momentum (au)");
^
/Users/couet/roottest/basic.C:88:4: error: use of undeclared identifier 'plot4d'
plot4d->GetZaxis()->SetTitle("Z-Momentum (au)");
^
/Users/couet/roottest/basic.C:89:4: error: use of undeclared identifier 'plot4d'
plot4d->GetXaxis()->SetTitleOffset(1.5);
^
/Users/couet/roottest/basic.C:90:4: error: use of undeclared identifier 'plot4d'
plot4d->GetYaxis()->SetTitleOffset(1.8);
^
/Users/couet/roottest/basic.C:91:4: error: use of undeclared identifier 'plot4d'
plot4d->GetZaxis()->SetTitleOffset(1.5);
^
/Users/couet/roottest/basic.C:92:4: error: use of undeclared identifier 'plot4d'
plot4d->GetXaxis()->CenterTitle(true);
^
/Users/couet/roottest/basic.C:93:4: error: use of undeclared identifier 'plot4d'
plot4d->GetYaxis()->CenterTitle(true);
^
/Users/couet/roottest/basic.C:94:4: error: use of undeclared identifier 'plot4d'
plot4d->GetZaxis()->CenterTitle(true);
^
root [1]
Can you check if the new one is working for you?
The previous one also working fine for me. May be as I am using Windows!!
I am attaching the output root file as well if it helps.
Best regards,
Arnab
With COLZ and 4 variables there is no binning. A dot is drawn at the position x y x and the color of the dot is computed according to the 4th variable. If you want a 3D histogram you can fill it as you did before and then draw it with one the the 3D histogram ploting options listed here.