# Jsroot unable to render saved TRatioPlot

**URL:** <https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114>\
**Category:** ROOT\
**Tags:** jsroot\
**Created:** [March 12, 2025, 9:09am UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114 "2025-03-12T09:09:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![loopset](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3ab097/32.png) [@loopset](https://root-forum.cern.ch/u/loopset)\
**Post date:** [March 12, 2025, 9:09am UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114/1 "2025-03-12T09:09:57Z")

</div>

Hello all,

I’ve implemented a simple website to display some canvas stored in a GitHub repo by using [jsroot online](https://root.cern/js/latest). My approach is to create locally some .root files with `TCanvas->SaveAs("name.root")` and then push them to the repository.

However, I’ve added a `TCanvas` that contains a `TRatioPlot` residual figure but jsroot is unable to render the contents properly: only one of the pads is drawn and it is unreactive to any gestures (zooming, axis, etc). On the contrary, if I open the file locally and `Draw()`the canvas, everything works fine. This is the expected output:

 ![Captura de pantalla de 2025-03-12 10-01-45](https://root-forum.cern.ch/uploads/default/original/3X/c/0/c0070e1d69424e26d367eb3889d1860c80b652ff.png)

The `TCanvas` I want to display is `cFit` in [this location](https://root.cern/js/latest/?file=https://loopset.github.io/e796-analysis/website/RootFiles/dd.root&status=size&layout=tabs&noselect&title=e796%2020O(d,d)) (it will open the online jsroot browser). These are the lines that create the canvas:

```auto
    // h: a TH1D* pointer
    // model: a custom fitting function
    // res: TFitResult
    auto* c {new TCanvas {TString::Format("cGF%d", cCount), title.c_str()}};
    // Create a legend
    auto* leg {new TLegend {0.5, 0.6, 0.9, 0.9}};
   
    auto* clone {(TH1D*)h->Clone()};
    clone->GetXaxis()->SetRangeUser(exmin, exmax);
    clone->SetStats(false);
    // Model pointer
    auto* ptr {new Fitters::Model {}};
    *ptr = model;
    // Wrap into TF1
    auto* tf1 {new TF1 {"fitfunc", [=](double* x, double* p) { return (*ptr)(x, p); }, exmin, exmax,
                        static_cast<int>(ptr->NPar())}};
    tf1->SetParameters(res.Parameters().data());
    tf1->SetNpx(2000);
    // And append to funtion list
    clone->GetListOfFunctions()->Clear();
    clone->GetListOfFunctions()->Add(tf1);
    // And ratio plot now!
    auto* ratio {new TRatioPlot {clone, "", &res}};
    ratio->SetH1DrawOpt("e"); // visualize errors for histogram
    ratio->SetGraphDrawOpt("p"); // same for residuals
    ratio->Draw();
    // std::cout << "Canvas : " << c << '\n';
    // std::cout << "up : " << ratio->GetUpperPad() << '\n';
    // std::cout << "low : " << ratio->GetLowerPad() << '\n';
    // std::cout << "gPad : " << gPad << '\n';
    // And draw the other things
    // ratio->GetUpperPad()->cd();
    // DrawGlobalFit(nullptr, hfits, leg, labels);
    c->cd();

```

Any help would be highly appreciated. Thanks in advance!

ROOT v6.32.02  
Built for linuxx8664gcc on Jun 18 2024, 04:33:34  
From tags/v6-32-02@v6-32-02  
With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

---

<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:** [March 12, 2025, 9:13am UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114/2 "2025-03-12T09:13:13Z")

</div>

Hi,

Can you upload here ROOT file with such `TRatioPlot`.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![loopset](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3ab097/32.png) [@loopset](https://root-forum.cern.ch/u/loopset)\
**Post date:** [March 12, 2025, 9:38am UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114/3 "2025-03-12T09:38:07Z")

</div>

Hi,

It’s this one:  
[dd.root](https://root-forum.cern.ch/uploads/short-url/yfh43x1BKDiEkSSkhpZnoGtBp9t.root) (716,0 KB)

Thanks!

---

<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:** [March 12, 2025, 2:55pm UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114/4 "2025-03-12T14:55:58Z")

</div>

Hi,

You hit two problems in JSROOT, which are fixed now in master branch.

First was simple. JSROOT had bug concerning latex parsing which starts  
with `^` symbol like `^{20} O(d,d)`

Second was not `TRatioPlot` itself, but `RooFit::FitResult` object stored inside.  
It was not properly handled by JSROOT I/O and therefore display of such incomplete  
object was not possible.

Both problems can be detected in console output of the browser.  
But now it should work. Like:

[dd.root/cFit](https://root.cern/js/dev/?file=https://root-forum.cern.ch/uploads/short-url/yfh43x1BKDiEkSSkhpZnoGtBp9t.root&item=cFit)

[dd.root/c0](https://root.cern/js/dev/?file=https://root-forum.cern.ch/uploads/short-url/yfh43x1BKDiEkSSkhpZnoGtBp9t.root&item=c0)

[dd.root/cFitter0](https://root.cern/js/dev/?file=https://root-forum.cern.ch/uploads/short-url/yfh43x1BKDiEkSSkhpZnoGtBp9t.root&item=cFitter0)

You can use JSROOT from git repository or from `https://root.cern/js/dev/`.

Fixes will be applied later to ROOT master, 6.34 and 6.32 branches.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![loopset](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3ab097/32.png) [@loopset](https://root-forum.cern.ch/u/loopset)\
**Post date:** [March 12, 2025, 5:47pm UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114/5 "2025-03-12T17:47:37Z")

</div>

Indeed, that solves the issue! Thank you 🙂

---

<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:** [March 26, 2025, 5:48pm UTC](https://root-forum.cern.ch/t/jsroot-unable-to-render-saved-tratioplot/63114/6 "2025-03-26T17:48:10Z")

</div>

Closed on March 26, 2025, 5:48pm UTC

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