question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set Axis titles for Tgraph?

See original GitHub issue

Hey, Is there a way to name x and y axis? I’ve found this closed issue that was supposed to add the functionality in 5.2, but haven’t found anything in the changelog. There’s nothing about in the JSROOT documentation and fXaxis and fYaxis are both undefined for TGraph objects.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
linevcommented, Dec 28, 2021

https://root.cern/js/latest/api.htm#custom_html_tlegend

Here is example of TMultiGraph with custom fHistogram to draw labels instead of numbers. And this is source:

https://github.com/root-project/jsroot/blob/master/demo/multigraph_legend.htm

If you have problems, try to create reproducer using web site like https://jsfiddle.net/

1reaction
linevcommented, Dec 20, 2021

Hi,

fXaxis and fYaxis objects are not existing in TGraph - they belong to histogram object, which stored in fHistogram data member. Like in example from #126 you can create histogram object and assigned it to the TGraph:

         let h1 = JSROOT.createHistogram("TH1I", 20);
         h1.fName = "axis_draw";
         h1.fXaxis.fTitle = "xaxis";
         h1.fYaxis.fTitle = "yaxis";
         h1.fXaxis.fXmin = -60;
         h1.fXaxis.fXmax = +60;

         let gr = JSROOT.createTGraph(3, [1,2,3], [5,2,5]);
         gr.fHistogram = h1;

This functionality should be working since jsroot 5.2 - with some adjustments done for 6.0 release.

Regards, Sergey

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting titles for TGraphs - ROOT Forum
Try: graph->SetTitle(“global title;X axis title;Y axis title;Z axis title”);. This works while the ...
Read more >
TGaxis Class Reference - ROOT
After an axis has been created, TGaxis::ChangeLabel allows to define new text attributes for a given label. A fine tuning of the labels...
Read more >
Re: How to define the x and y axies label on TMultigraph - ROOT
>>> Does anyone help me how to make x and y axis label on TMultigraph? >>> or can anyone guide me to find...
Read more >
TGraph Class Reference - ROOT
A TGraph has the default title and name "Graph". To change the default title and name SetTitle and SetName should be called on...
Read more >
RootTalk: Re: [ROOT] Setting text size of title of TGraph - CERN
By title i mean the box in upper > left that is set by TCanvas::SetTitle(), not the titles of the axes. I >...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found