Draw a graph with text attached to each point.
The text is drawn in a TExec function attached to the TGraph, therefore if the a graph's point is moved interactively, the text will be automatically updated.
void gr202_textmarkers() {
gr->SetTitle(
"A Simple Graph Example with Text");
auto ex =
new TExec(
"ex",
"drawtext();");
gr->GetListOfFunctions()->Add(
ex);
}
}
{
auto g = (
TGraph*)
gPad->GetListOfPrimitives()->FindObject(
"Graph");
l.PaintText(
x,
y+0.2,
Form(
"(%4.2f,%4.2f)",
x,
y));
}
}
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TExec is a utility class that can be used to execute a C++ command when some event happens in a pad.
void drawtext(double x, double y, int f, const char *s)
- Author
- Olivier Couet
Definition in file gr202_textmarkers.C.