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 graphtext() {
auto ex =
new TExec(
"ex",
"drawtext();");
}
}
{
auto g = (
TGraph*)
gPad->GetListOfPrimitives()->FindObject(
"Graph");
l.PaintText(
x,
y+0.2,
Form(
"(%4.2f,%4.2f)",
x,
y));
}
}
char * Form(const char *fmt,...)
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
TExec is a utility class that can be used to execute a C++ command when some event happens in a pad.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
virtual void SetTitle(const char *title="")
Change (i.e.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
TList * GetListOfFunctions() const
To draw Mathematical Formula.
virtual void Add(TObject *obj)
void drawtext(double x, double y, int f, const char *s)
- Author
- Olivier Couet
Definition in file graphtext.C.