# Label Points on Log-Log graph

**URL:** <https://root-forum.cern.ch/t/label-points-on-log-log-graph/50679>\
**Category:** Newbie\
**Created:** [July 5, 2022, 9:01pm UTC](https://root-forum.cern.ch/t/label-points-on-log-log-graph/50679 "2022-07-05T21:01:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OmnipotentEntity1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/omnipotententity1/32/30206_2.png) [@OmnipotentEntity1](https://root-forum.cern.ch/u/OmnipotentEntity1)\
**Post date:** [July 5, 2022, 9:01pm UTC](https://root-forum.cern.ch/t/label-points-on-log-log-graph/50679/1 "2022-07-05T21:01:11Z")

</div>

So I’m trying to use Root to graph a bunch of functions and points, and then label these points. I’m following the graphtext.C example (cannot link to it due to new user restrictions), but my labels don’t seem to be showing up at all.

I suspect that I _might_ be running into an issue between user coordinates and the large scale of my data (moreover, I’m using log axes). When I try to paint the labels using NCD coordinates they show up fine, but converting from user coordinates to NCD coordinates seems to be discouraged, and moreover it’s pretty difficult and tedious to hunt for the correct scaling factors.

Here is a SCCE that avoids some of the complixities of plotting a whole bunch of curves and finding the proper graph buried in the multigraph. Just trying to label some points on a log-log graph and failing.

```auto
void drawtext() {
  int i,n;
  double x,y;

  TText t;
  t.SetTextAlign(13);
  t.SetTextColor(kBlue);
  t.SetTextFont(43);
  t.SetTextSize(10000); // I don't know where the limit is, but much larger than this results in an error

  auto g = (TGraph*)gPad->GetPrimitive("Points");

  n = g->GetN();

  const char * labels[] = {"Reactor", "Experiment (torus)", "Experiment (pinch)", "Ionosphere", "Radiofreq plasma", "Flame", "Laser", "Space"};

  for (i=0; i<n; i++) {
    g->GetPoint(i,x,y);
    t.PaintText(x, y, labels[i]);
  }
}

void scce() {
  const double xmin = 1e6;
  const double xmax = 1e28;

  const double ymin = 1e-2;
  const double ymax = 1e5;

  auto cv = new TCanvas("cv", "cv", 1920, 1200);
  cv->SetLogx();
  cv->SetLogy();
  cv->SetGrid();

  // plasma points
  const int point_count = 8;
  const double ns[point_count] = {1e20, 1e19, 1e23, 1e11, 1e17, 1e14, 1e25, 1e6};
  const double ts[point_count] = {3e4, 100, 1000, 0.05, 1.5, 0.1, 100, 0.01};
  auto *g_points = new TGraph();
  g_points->SetName("Points");

  auto ex = new TExec("ex", "drawtext();");
  g_points->GetListOfFunctions()->Add(ex);

  g_points->SetTitle("Various Example Plasmas");
  g_points->SetMarkerStyle(20);
  for (int i = 0; i < point_count; ++i) {
    g_points->SetPoint(i, ns[i], ts[i]);
  }
  g_points->GetXaxis()->SetLimits(xmin, xmax);
  g_points->SetMinimum(ymin);
  g_points->SetMaximum(ymax);
  g_points->Draw("AP");
}

```

Note: I have also tried taking the log10 of both `x` and `y` before drawing the text, but that doesn’t seem to affect things.

* * *

_ROOT Version:_ 6.24/06  
_Platform:_ Linux  
_Compiler:_ GCC 11.3.0

* * *

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [July 6, 2022, 4:28am UTC](https://root-forum.cern.ch/t/label-points-on-log-log-graph/50679/2 "2022-07-06T04:28:18Z")

</div>

> [@OmnipotentEntity1](#):
>
> ` t.SetTextSize(10000);`

Why 10000? For [font precision](https://root.cern/doc/master/classTAttText.html#ATTTEXT5) 3 (as in 43, in your case) this size is in pixels. Try 10 and go from there.

---

<div class="post-metadata">

**Author:** ![OmnipotentEntity1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/omnipotententity1/32/30206_2.png) [@OmnipotentEntity1](https://root-forum.cern.ch/u/OmnipotentEntity1)\
**Post date:** [July 6, 2022, 4:44am UTC](https://root-forum.cern.ch/t/label-points-on-log-log-graph/50679/3 "2022-07-06T04:44:20Z")

</div>

I tried a number of different sizes. I started with smaller sizes, such as 10 and 20, but I went bigger so that if the text was printing anywhere remotely near to the canvas area it would show up.

Also the example graphtext.C used text size 0.025 (but perhaps a different font precision, I don’t recall, and I’ve been mucking around with the exact text settings a lot) and through trial and error I determined in that particular situation it was related to the user coordinate size, so I figured because my user coordinates are very large I would also need a very large font size.

Either way setting the font size to 10 does not help, but thanks for the documentation reference.

---

<div class="post-metadata">

**Author:** ![OmnipotentEntity1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/omnipotententity1/32/30206_2.png) [@OmnipotentEntity1](https://root-forum.cern.ch/u/OmnipotentEntity1)\
**Post date:** [July 6, 2022, 4:48am UTC](https://root-forum.cern.ch/t/label-points-on-log-log-graph/50679/4 "2022-07-06T04:48:29Z")

</div>

Please excuse me. Apparently, I spoke too soon. I don’t know exactly what I tested before, but that particular combination seems to work as expected. And I feel… actually kinda dumb now. Thanks.
