# Two plotting aesthetics questions (TGraph and TAxis)

**URL:** <https://root-forum.cern.ch/t/two-plotting-aesthetics-questions-tgraph-and-taxis/61900>\
**Category:** Newbie\
**Created:** [October 10, 2024, 5:18am UTC](https://root-forum.cern.ch/t/two-plotting-aesthetics-questions-tgraph-and-taxis/61900 "2024-10-10T05:18:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [October 12, 2024, 5:02am UTC](https://root-forum.cern.ch/t/two-plotting-aesthetics-questions-tgraph-and-taxis/61900/5 "2024-10-12T05:02:17Z")

</div>

For the function line issue, it’s because your functions are defined from 9.5 (or 10.5 as you would like) to 200 (even though you are only plotting up to 37), and by default ROOT draws TF1 by sampling 100 points in x, so there aren’t enough points; you can change that number with TF1::SetNpx:  
[https://root.cern/doc/master/classTF1.html#a6a04facaa58306988a3189b4e8713aa5](https://root.cern/doc/master/classTF1.html#a6a04facaa58306988a3189b4e8713aa5)  
For your case, you could increase that npx (around 500 seems to look ok), or reduce the upper limit of your functions (e.g. to 40), or a combination of both. Using DrawFrame as @couet suggested, and these 2 options:

```auto
  TCanvas *c1 = new TCanvas("c1","",700,500);

  gStyle->SetOptStat(0);
  gStyle->SetLegendBorderSize(0);

  c1->DrawFrame(0,0,37,1.30);

  TGaxis *axis = new TGaxis(37,0.0, 37, 1.15,0,1.5,51,"+L");
  axis->SetNdivisions(505);
  axis->SetLabelFont(gStyle->GetLabelFont("Y"));
  axis->SetTitleFont(gStyle->GetTitleFont("Y"));
  axis->SetTitle(" Background Rate [MHz]");
  axis->CenterTitle();
  axis->SetTitleSize(0.08);
  axis->SetTitleOffset(0.5);
  axis->Draw();

  TLine *line = new TLine(10.5,0,10.5,1.30);
  line->SetLineStyle(2);
  line->Draw();

  double Act_Zr88_0 = 1.11; // GBq
  double tHalf_Zr88 = 83.4; // days
  double tHalf_Y88 = 106.629; // days
  double Eff_Zr88 = 0.0002;
  double Eff_Y88 = 0.0035;

  // BLUE, increasing Npx
  TF1 *fBkg_Zr88 = new TF1("fBkg_Zr88","1000*[3]*[0]*exp(-log(2.0)*x/[1])",10.5,200);
  fBkg_Zr88->SetParameters(Act_Zr88_0, tHalf_Zr88, tHalf_Y88, Eff_Zr88);
  fBkg_Zr88->SetLineColor(kBlue+2);
  fBkg_Zr88->SetLineWidth(4);
  fBkg_Zr88->SetLineStyle(7);
  fBkg_Zr88->SetNpx(500);
  fBkg_Zr88->Draw("same");

  // RED, reducing range of TF1
  TF1 *fBkg_Y88 = new TF1("fBkg_Y88","1000*[4]*(1.0/[1])/(1.0/[2]-1.0/[1])*[0]*(exp(-log(2.0)*x/[1])-exp(-log(2.0)*x/[2]))",10.5,40);
  fBkg_Y88->SetParameters(Act_Zr88_0, tHalf_Zr88, tHalf_Y88, Eff_Zr88, Eff_Y88);
  fBkg_Y88->SetLineColor(kRed+2);
  fBkg_Y88->SetLineWidth(4);
  fBkg_Y88->SetLineStyle(7);
  fBkg_Y88->Draw("same");

```

 ![c1](https://root-forum.cern.ch/uploads/default/original/3X/6/b/6bc99d675b7f15e7c7d42ebb69b6a3a02941a8b7.png)

---

_[View the full topic](https://root-forum.cern.ch/t/two-plotting-aesthetics-questions-tgraph-and-taxis/61900)._
