# Changing labels size on TF1 and TGraph

**URL:** <https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072>\
**Category:** Newbie\
**Tags:** jsroot\
**Created:** [November 27, 2026, 8:24am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072 "2026-11-27T08:24:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Georgios](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/eb9ed0/32.png) [@Georgios](https://root-forum.cern.ch/u/Georgios)\
**Post date:** [November 27, 2026, 8:24am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/1 "2026-11-27T08:24:59Z")

</div>

* * *

_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:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

Hi,

is there a way to change TF1, TGraph axes parameters like in TH1?

I know that TF1 and TGraph mechanisms are different and one has to use painter after draw to change axes colors, axes labels size etc but using this with awaits is a bit complicated and not so clean (i let users to create JSROOT graphs in ace code editor).

Maybe you plan to put such an option (ex. just using f1.fXAxis.fLabelsSize = 0.07) in the future that is why i am asking, so if you do let me know.

Regards,

Georgios

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 27, 2026, 8:35am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/2 "2026-11-27T08:35:00Z")

</div>

Hi Georgios,

If you create objects with JavaScript, you can use following code:

```auto
      import { createTGraph, createHistogram, draw } from 'jsroot';
      const npoints = 5, xpts = [1,2,3,4,5], ypts = [3,5,3,5,3];
      const graph = createTGraph(npoints, xpts, ypts);
      const h1 = createHistogram('TH1I', 20);
      h1.fName = 'axis_draw';
      h1.fTitle = 'Graph title';
      h1.fXaxis.fLabelSize = 0.05;
      graph.fHistogram = h1;
      draw('divid', graph, 'AL');

```

Some of such examples you will find in: [https://github.com/root-project/jsroot/tree/master/demo](https://github.com/root-project/jsroot/tree/master/demo)

like: [JavaScript ROOT API examples](https://root.cern/js/latest/api.htm#custom_html_tlegend)

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![Georgios](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/eb9ed0/32.png) [@Georgios](https://root-forum.cern.ch/u/Georgios)\
**Post date:** [November 27, 2026, 8:40am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/3 "2026-11-27T08:40:54Z")

</div>

> [@linev](#):
>
> ```auto
> const npoints = 5, xpts = [1,2,3,4,5], ypts = [3,5,3,5,3];
> const graph = createTGraph(npoints, xpts, ypts);
> const h1 = createHistogram('TH1I', 20);
> h1.fName = 'axis_draw';
> h1.fTitle = 'Graph title';
> h1.fXaxis.fLabelSize = 0.05;
> graph.fHistogram = h1;
> draw('divid', graph, 'AL');
> 
> ```

Thanks for the link,

this wont work for me,

i see now the new histogram with axes labels correctly changed, but graph line went away!

Here is a code that works but it is not good enough for users who are typing simple javascript JSROOT commands in a code editor

```auto
let f1 = create("TF1", "sin(x)/x", -Math.PI, Math.PI);
f1.fName = "f1";

let f2 = create("TF1", "sin(x)*x", -Math.PI, Math.PI);
f2.fName = "f2";
f2.fLineColor = 3;

let l = create("TList");
l.arr = [f1, f2];

let painter = await draw(l, 'gridxy');

let main = painter.getMainPainter();
main.getHisto().fXaxis.fLabelSize = 0.08;
await painter.redrawPad();

```

i mean the last part is a bit hard for them.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 27, 2026, 8:55am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/4 "2026-11-27T08:55:19Z")

</div>

Hi,

I add draw\_graph.htm demo to repository.

```auto
   <script type='module'>
      import { draw, createTGraph, createHistogram, kNoStats } from 'jsroot';
      const npoints = 5, xpts = [1,2,3,4,5], ypts = [3,5,3,5,3];
      const graph = createTGraph(npoints, xpts, ypts);
      graph.fTitle = 'Graph title';
      graph.fLineColor = 3;
      graph.fLineWidth = 4;
      graph.fLineStyle = 2;
      const h1 = createHistogram('TH1I', 20);
      h1.fName = 'axis_draw';
      h1.fXaxis.fLabelSize = 0.05;
      h1.fXaxis.fXmin = 0;
      h1.fXaxis.fXmax = 6;
      h1.fMinimum = 0;
      h1.fMaximum = 8;
      h1.fBits |= kNoStats;
      graph.fHistogram = h1;
      draw('drawing', graph, 'AL*');
   </script>

```

Here is link: [https://jsroot.gsi.de/dev/demo/draw\_graph.htm](https://jsroot.gsi.de/dev/demo/draw_graph.htm)

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 27, 2026, 8:56am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/5 "2026-11-27T08:56:36Z")

</div>

> [@Georgios](#):
>
> ```auto
> let main = painter.getMainPainter();
> main.getHisto().fXaxis.fLabelSize = 0.08;
> await painter.redrawPad();
> 
> ```

This is also possible way - but leads to small “flicking” when drawing graph

---

<div class="post-metadata">

**Author:** ![Georgios](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/eb9ed0/32.png) [@Georgios](https://root-forum.cern.ch/u/Georgios)\
**Post date:** [November 27, 2026, 9:07am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/6 "2026-11-27T09:07:50Z")

</div>

Neither is a solution in my opinion, nor yours nor mine.

A user would waiting to use the same simple technique for changing axes parameters simply (with graph.fXAxis.fLabelsSize) for all graphical containers (TF1, TGraph, TH1).

But since it is difficult to achieve such a solution we will use some workarounds.

Best regards,

Georgios

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 27, 2026, 9:44am UTC](https://root-forum.cern.ch/t/changing-labels-size-on-tf1-and-tgraph/65072/7 "2026-11-27T09:44:06Z")

</div>

> [@Georgios](#):
>
> A user would waiting to use the same simple technique for changing axes parameters simply (with graph.fXAxis.fLabelsSize) for all graphical containers (TF1, TGraph, TH1).

This is how ROOT graphics organized.  
Axes for `TGraph` and `TF1` are drawn using histogram classes.  
Therefore to get custom axes properties one have to create histogram object.  
In C++ interface ROOT provides some wrappers (like `TGraph::GetXaxis()`) which creates histogram behind the scene. JSROOT does not have such functionality.

Normally all such objects can be created and configured with ROOT C++ macros and stored in JSON files. Then JSROOT used only to display data.
