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()
{
TCanvas *
c =
new TCanvas(
"c",
"A Simple Graph Example with Text", 700, 500);
auto ex =
new TExec(
"ex",
"drawtext();");
for (
Int_t i = 0; i <
n; i++) {
}
}
{
for (i = 0; i <
n; i++) {
l.PaintText(
x,
y + 0.2,
Form(
"(%4.2f,%4.2f)",
x,
y));
}
}
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
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.
TList * GetListOfFunctions() const
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
void SetTitle(const char *title="") override
Change (i.e.
To draw Mathematical Formula.
void Add(TObject *obj) override
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void drawtext(double x, double y, int f, const char *s)
- Author
- Olivier Couet
Definition in file graphtext.C.