Skip to content

Commit 55a2fbc

Browse files
authored
Add the missing section (root-project#679)
* Add the missing section * remove .ch
1 parent 0e5a5d8 commit 55a2fbc

File tree

1 file changed

+73
-7
lines changed

1 file changed

+73
-7
lines changed

manual/graphics/index.md

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ primitives of any type (graphs, histograms, shapes, tracks, etc.).
2121

2222
Adding an element to a pad is done by the `Draw()` method of each class.
2323

24-
Painting a pad is done by the `Paint()` method of each object in the list of primitives.
24+
Painting a pad is done by the automatic call to `Paint()` method of each object in the list of primitives.
2525

2626
{% include tutorials name="Graphics" url="graphics" %}
2727

2828
## Graphic classes
2929

30-
ROOT provides numerous graphic classes, of which the following are among the most used:
30+
ROOT provides [numerous graphic classes](https://root.cern/doc/master/group__Graphics.html), of which the following are among the most used:
3131

3232
- {% include ref class="TCanvas" %}
3333

@@ -134,6 +134,18 @@ method:
134134
- _Text and Latex_: Use {% include ref class="TText" %} to draw simple text. {% include ref class="TLatex" %} for complex text like mathematical formulas. Text can be embedded in a box using {% include ref class="TPaveLabel" %}, {% include ref class="TPaveText" %} and {% include ref class="TPavesText" %}.
135135
- and [_more ..._](https://root.cern/doc/master/group__BasicGraphics.html)
136136

137+
138+
## Colors and color palettes
139+
140+
Colors are managed by the class {% include ref class="TColor" %}. A color is defined by its
141+
RGB or HLS components. It can be accessed via an
142+
[index](https://root.cern/doc/master/classTColor.html#C00) or
143+
[by name ](https://root.cern/doc/master/classTColor.html#C02) for the predefined colors.
144+
Colors can be grouped in [palettes](https://root.cern/doc/master/classTColor.html#C05). More
145+
than 60 [High quality palettes](https://root.cern/doc/master/classTColor.html#C06) are predefined.
146+
Color can also be [transparent](https://root.cern/doc/master/classTColor.html#C07).
147+
148+
137149
## Graphical objects attributes and styles
138150

139151
There are the following classes for changing the attributes of graphical objects:
@@ -211,7 +223,7 @@ the {% include ref class="TGaxis" %} class.
211223
_**Example**_
212224

213225
{% highlight C++ %}
214-
TAxis *axis = histo->GetXaxis();
226+
auto axis = histo->GetXaxis();
215227
{% endhighlight %}
216228

217229
### Setting the axis title
@@ -239,7 +251,7 @@ The axis graphical attributes are managed via the class {% include ref class="TA
239251
_**Example**_
240252

241253
{% highlight C++ %}
242-
TAxis *axis = histo->GetXaxis();
254+
auto axis = histo->GetXaxis();
243255
axis->SetLabelColor(kRed); // change the labels'color to red
244256
{% endhighlight %}
245257

@@ -251,10 +263,24 @@ method to set the number of divisions for an axis.
251263
_**Example**_
252264

253265
{% highlight C++ %}
254-
TAxis *axis = histo->GetXaxis();
266+
auto axis = histo->GetXaxis();
255267
axis->SetNdivisions(510); // Set 10 primary divisions and 5 secondary divisions.
256268
{% endhighlight %}
257269

270+
271+
### Labels tuning
272+
273+
Several [axis' attributes can be changed](https://root.cern/doc/master/classTGaxis.html#GA06).
274+
For instance the [size](https://root.cern/doc/master/classTAttAxis.html#a59684f3441f945f1b2d4e6970ad3d1b5),
275+
the [distance to the axis](https://root.cern/doc/master/classTAttAxis.html#a73c13dee8312d852b41f2234021e2ffc),
276+
the [alignment](https://root.cern/doc/master/classTAxis.html#a0abc742bbcfc963863ab3668ce810cc6) etc ...
277+
278+
[SetMaxDigits()](https://root.cern/doc/master/classTAttAxis.html#aac05911a829616a11bb659f88a10cbad)
279+
set the maximum number of digits permitted for the axis labels above which the notation
280+
with $10^N$ is used.
281+
282+
Labels can also be tuning individually thanks to [ChangeLabel()](https://root.cern/doc/master/classTGaxis.html#GA10a).
283+
258284
### Setting the axis range
259285

260286
- Use [TAxis::SetRange()](https://root.cern/doc/master/classTAxis.html#aed523b084d6b3f24f6b1128d7810e199){:target="_blank"} or [TAxis::SetRangeUser()](https://root.cern/doc/master/classTAxis.html#ac85f8261dedc23bbe68f90afd196cdb8){:target="_blank"} to zoom the axis.
@@ -266,7 +292,7 @@ The `SetRangeUser()` method parameters are user coordinates. If the start or end
266292
middle of a bin the resulting range is approximation. It finds the low edge bin for the
267293
start and the high edge bin for the high.
268294

269-
For a general description see the ["How to set ranges on axis" FAQ](https://root-forum.cern.ch/t/how-to-set-ranges-on-axis/28254).
295+
For a general description see the ["How to set ranges on axis" FAQ](https://root-forum.cern/t/how-to-set-ranges-on-axis/28254).
270296

271297
### Setting time units for axis
272298

@@ -433,7 +459,7 @@ A sub-pad is to be built into the active pad (pointed by `gPad`). First, the sub
433459
build using the {% include ref class="TPad" %} constructor.
434460

435461
{% highlight C++ %}
436-
root [0] spad1 = new TPad("spad1","The first subpad",.1,.1,.5,.5)
462+
root [0] auto spad1 = new TPad("spad1","The first subpad",.1,.1,.5,.5)
437463
{% endhighlight %}
438464

439465
The NDC (normalized coordinate system) coordinates are specified for the lower left point `(0.1, 0.1)` and for the upper right point `(0.5, 0.5)`.<br>
@@ -590,12 +616,43 @@ p->PixeltoY(py - p->GetWh());
590616
{% endhighlight %}
591617

592618

619+
### Setting the Log Scale
620+
621+
Setting the scale to logarithmic or linear is a pad's attribute because you may want to
622+
draw the same histogram in linear scale in one pad and in log scale in another pad.
623+
Setting log scale does not propagate to sub-pads.
624+
625+
[TPad defines log scale](https://root.cern/doc/master/classTPad.html#ae79fc15f5e392ba9edf59e18bb3aecd4)
626+
for the three directions `x`, `y` and `z`.
627+
628+
_**Example**_
629+
630+
{% highlight C++ %}
631+
root [0] gPad->SetLogx(1); // Set the x axis to log in the current pad
632+
root [1] gPad->SetLogy(0); // Set the y axis to linear in the current pad
633+
{% endhighlight %}
634+
635+
593636
### Copying a canvas
594637

595638
- Use the [TCanvas::DrawClonePad](https://root.cern/doc/master/classTCanvas.html#afcb8727555c9c2be024eb307fd3d295a){:target="_blank"} method to make a copy of the canvas.
596639

597640
You can also use the [TObject:DrawClone()](https://root.cern/doc/master/classTObject.html#a7cd0f76ae1791c469f9472a9d4c8d6f9){:target="_blank"} method, to draw a clone of this object in the current selected pad.
598641

642+
### Printing a canvas
643+
644+
Once a canvas is created and shows plots ready to be included in a publication as a `.png`
645+
or a `.pdf` image, the [Print()](https://root.cern/doc/master/classTPad.html#ae44fee7e51d69841c1dce4b899eee14d)
646+
method can be used. All the standard output formats are provided.
647+
648+
_**Example**_
649+
650+
{% highlight C++ %}
651+
auto c = new TCanvas(); // Create a canvas
652+
h->Draw(); // Draw an histogram in the canvas
653+
c->Print("c1.pdf"); // Save the canvas in a .pdf file
654+
{% endhighlight %}
655+
599656
## Drawing objects with special characters in its name
600657

601658
In general, avoid using objects that containing special character like `\`, `/`, `#` etc. in the objects names. Also object names starting with a number might be not accessible from the ROOT command line.
@@ -644,3 +701,12 @@ void draw_object(const char *file_name = "myfile.root", const char *obj_name = "
644701
}
645702

646703
{% endhighlight %}
704+
705+
## 3D graphics
706+
707+
[3D graphics tools](https://root.cern/doc/master/group__Graphics3D.html) for "Event Display",
708+
"Basic 3D" and OPen GL rendering are provided.
709+
710+
{% include tutorials name="Geometry" url="geom" %}
711+
<br>
712+
{% include tutorials name="OpenGL" url="gl" %}

0 commit comments

Comments
 (0)