3The
TCanvas class is used to create the canvas
on which graphical objects such
as histograms can be drawn. The following
4is
a simple example of typical usage:
12 h = ROOT.TH1D("h",
"h", 100, -5, 5)
13 h.Fill(numpy.random.normal(
size=1000))
20if __name__ ==
"__main__":
21 print(
"Before plot function")
23 print("After
plot function")
26Note the optional argument `block` passed to the `
Draw` method of the canvas. If set to `True`, it will block the script
27execution and run the
ROOT graphics event loop until the <space> key is pressed. This allows interacting with the
28canvas and its content until necessary, then move
on with the rest of the script.
30Another relevant use case is drawing live updates
on a canvas, shown in the example below. In this case, the canvas is
31setup by first creating the
object to be drawn and drawing it once. Then, the
object is updated in
a for loop, which
32could represent
for example an incoming stream of
data with which the histogram should be filled. Each time the
plot
33should be updated, the `ModifiedUpdate` function should be called. This will immediately show the new contents
on the
34plot. Finally, the canvas is drawn again with `
Draw(block=True)` at the end of the loop so that it stays visible and can
44 h = ROOT.TH1D("h",
"h", 100, -5, 5)
48 h.Fill(numpy.random.normal(
size=10))
52if __name__ ==
"__main__":
53 print(
"Before plot function")
55 print(
"After plot function")
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
virtual void Draw(Option_t *option="")
Default Draw method for all objects.