Orient TPaveText

Consider this example:

TCanvas * c = new TCanvas;
  TH1 * h = new TH1F("h", "h", 5, 0.0, 5.0);
  h -> Draw();
  TPaveText * pt = new TPaveText(0.1, 0.1, 2.8, 0.3);
  pt -> AddText("text");
  pt -> SetTextAngle(45);
  pt -> Draw();

The output is

The text is horizontal even though I have set the angle at 45 deg. What is wrong?

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

See the first example of the documentation.
Remove pt -> SetTextAngle(45); and after drawing, add:

 TText *t2 = pt->GetLineWith("text");

and you may need to also add c->Modified(); to update the canvas.

What would be the corresponding option for TLatex?

How can I centre TLatex on a specific point?


At https://root.cern/doc/master/classTLatex.html I see no examples of text direction being changed, nor any option how I could retrieve text from TLatex

To understand better what are the possible options to orient a TLatex

  1. open an empty canvas
  2. go in View->Toolbar
  3. create a TLatex clicking on “L”
  4. position/ move/resize/ center the text
  5. save the canvas as a .C and look at the code generated.

I find there are many things unclear:

What is the meaning of the trailing “<” after gdfg?
I don’t know how to write #frac{a}{b} - pressing { generates an error

*ERROR<TLatex>: Error in syntax of  "#frac"
==> #frac{

Where are the functions to position/ move/resize/ center the text?

   TCanvas *c1 = new TCanvas("c1", "c1",10,45,700,527);

   TLatex *   tex = new TLatex(0.5,0.5,"Hello");

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.