Logo ROOT   6.10/00
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
bindings/pyroot/JupyROOT/README.md
Go to the documentation of this file.
1 # JupyROOT
2 A software layer to integrate Jupyter notebooks and ROOT.
3 
4 ## Installation
5 1. [Install ROOT6](https://root.cern.ch/building-root) (> 6.05)
6 2. Install dependencies: pip install jupyter metakernel
7 
8 ## Start using ROOTbooks
9 Set up the ROOT environment (`. $ROOTSYS/bin/thisroot.[c]sh`) and type in your
10 shell:
11 ```
12 root --notebook
13 ```
14 This will start a ROOT-flavoured notebook server in your computer.
15 
16 Alternatively, if you would like to use the Jupyter command directly, you
17 can do on Linux:
18 ```
19 cp -r $ROOTSYS/etc/notebook/kernels/root ~/.local/share/jupyter/kernels
20 jupyter notebook
21 ```
22 and on OSx:
23 ```
24 cp -r $ROOTSYS/etc/notebook/kernels/root /Users/$USER/Library/Jupyter/kernels/
25 jupyter notebook
26 ```
27 
28 Once the server is up, you can use ROOT with two kernels:
29 
30 1. ROOT C++: new kernel provided by ROOT
31 2. Python 2: already provided by Jupyter
32 
33 ## C++ ROOTbook
34 ROOT offers a C++ kernel that transforms the notebook in a ROOT prompt.
35 Embedded graphics, syntax highlighting and tab completion are among
36 the features provided by this kernel.
37 
38 An example of how you would plot a histogram in a C++ ROOTbook is:
39 ```cpp
40 TCanvas c;
41 TH1F h("h","ROOT Histo;X;Y",64,-4,4);
42 h.FillRandom("gaus");
43 h.Draw();
44 c.Draw();
45 ```
46 
47 ## Python ROOTbook
48 If you prefer to use Python, you can create a new Python 2 kernel and
49 import the ROOT libraries:
50 ```python
51 import ROOT
52 ```
53 And then you could write something like:
54 ```python
55 c = ROOT.TCanvas("c")
56 h = ROOT.TH1F("h","ROOT Histo;X;Y",64,-4,4)
57 ```
58 Additionally, you can mix Python and C++ in the same notebook
59 by using the **%%cpp** magic:
60 ```cpp
61 %%cpp
62 h->FillRandom("gaus");
63 h->Draw();
64 c->Draw();
65 ```
double write(int n, const std::string &file_name, const std::string &vector_type, int compress=0)
writing
TH1 * h
Definition: legend2.C:5
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:551
TArc * a
Definition: textangle.C:12
static double A[]
void example()
Definition: example.C:26
static double C[]
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3294
TRandom2 r(17)
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2851
The Canvas class.
Definition: TCanvas.h:31
int type
Definition: TGX11.cxx:120