# Set first axis number to draw

**URL:** <https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912>\
**Category:** ROOT\
**Created:** [July 22, 2022, 10:54am UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912 "2022-07-22T10:54:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdeberna](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/65b543/32.png) [@fdeberna](https://root-forum.cern.ch/u/fdeberna)\
**Post date:** [July 22, 2022, 10:54am UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/1 "2022-07-22T10:54:50Z")

</div>

Dear experts,

I need a very simple help in setting the first point to be drawn of a X-axis of a TGraph. In particular, not the default ‘0’ value but the ‘1’ or other.  
Moreover, how can I set to draw only odd points on the X-axis of my TGraph.

Thank you a lot for your collaboration

* * *

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

\_ROOT Version: ROOT 6.24/00  
_Platform:_ Windows 10

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 22, 2022, 11:11am UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/2 "2022-07-22T11:11:31Z")

</div>

The best is to use `ChangeLabel`. If you have a little example I can modify It to show you how to proceed.

---

<div class="post-metadata">

**Author:** ![fdeberna](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/65b543/32.png) [@fdeberna](https://root-forum.cern.ch/u/fdeberna)\
**Post date:** [July 22, 2022, 12:47pm UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/3 "2022-07-22T12:47:48Z")

</div>

Thank you a lot for your help.

With the following code I obtain the plots (o something like that):

```
    char nmMG[10];
    sprintf(nmMG, "Q2 M%d", Sz + 2);
    TMultiGraph* mg_comp_Stz_Q2 = new TMultiGraph();
    mg_comp_Stz_Q2->SetTitle(nmMG);

	int ngr_yrs = 2;//yrs= 2018, 2022
	TGraph** gr_comp_Stz_Q2 = new TGraph * [ngr_yrs];
	for (int ys = 0; ys < ngr_yrs; ys++) {
		gr_comp_Stz_Q2[ys] = new TGraph(nTotCha_Q, XY_gr_comp_Stz_Q2_2018_22[ys][0], XY_gr_comp_Stz_Q2_2018_22[ys][1]);
		gr_comp_Stz_Q2[ys]->SetLineColor(kBlack);
		gr_comp_Stz_Q2[ys]->SetMarkerStyle(20);
		gr_comp_Stz_Q2[ys]->SetMarkerSize(.7);
		if (ys == 0) gr_comp_Stz_Q2[ys]->SetMarkerColor(kBlue);
		if (ys == 1) gr_comp_Stz_Q2[ys]->SetMarkerColor(kRed);
		mg_comp_Stz_Q2->Add(gr_comp_Stz_Q2[ys], "lp");
	}
	mg_comp_Stz_Q2->Draw("ALP");

```

- They are about 70 points, thus I would like having the first number ob the X-axis equal to 1 and not to 0

Thank you again for your help

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 22, 2022, 12:49pm UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/4 "2022-07-22T12:49:49Z")

</div>

Can you provide à minimal working example showing the plot you get and I will modify it ?

---

<div class="post-metadata">

**Author:** ![fdeberna](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/65b543/32.png) [@fdeberna](https://root-forum.cern.ch/u/fdeberna)\
**Post date:** [July 22, 2022, 12:50pm UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/5 "2022-07-22T12:50:34Z")

</div>

I am sorry, I forgot to put plot:

 ![immagine](https://root-forum.cern.ch/uploads/default/original/3X/5/5/552250d6d3bd294fb9337158efd7d35e2ce80556.png)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 22, 2022, 12:58pm UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/6 "2022-07-22T12:58:12Z")

</div>

Try:

```cpp
mg_comp_Stz_Q2->Draw("ALP");
gPad->Modified(); gPad->Update();
mg_comp_Stz_Q2->GetHistogram()->GetXaxis()->SetLimits(0.5, 69.5); /* or maybe (1., 70.) */
gPad->Modified(); gPad->Update();

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 5, 2022, 12:58pm UTC](https://root-forum.cern.ch/t/set-first-axis-number-to-draw/50912/7 "2022-08-05T12:58:25Z")

</div>

Closed on August 5, 2022, 12:58pm UTC

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