# How to redraw preserving axis settings

**URL:** <https://root-forum.cern.ch/t/how-to-redraw-preserving-axis-settings/63265>\
**Category:** Newbie\
**Tags:** python, jsroot\
**Created:** [April 1, 2025, 8:01am UTC](https://root-forum.cern.ch/t/how-to-redraw-preserving-axis-settings/63265 "2025-04-01T08:01:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![frezzonico](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/a5b964/32.png) [@frezzonico](https://root-forum.cern.ch/u/frezzonico)\
**Post date:** [April 1, 2025, 8:01am UTC](https://root-forum.cern.ch/t/how-to-redraw-preserving-axis-settings/63265/1 "2025-04-01T08:01:27Z")

</div>

Hello,  
I am implementing a javascript dashboard which every second loads a .ROOT file and draws it in a div:

```js
let isFirstDraw = true;
async function update(){
    let file = await JSROOT.openFile(`dashboard/resources/${relPath}`);
    let obj = await file.readObject("c");

    if (isFirstDraw) {
      await JSROOT.draw("drawing", obj);
    } else {
      await JSROOT.redraw("drawing", obj);
    }

    isFirstDraw = false;
}

```

I want the redrawing to persist information such as whether the axes are in log scale, how do I do so?

As part of my tests I tried using `draw(dom, obj, "logy")`, which correctly sets the y axis to log scale, however using `redraw(dom, obj, "logy")` resets the axis to linear scale. Is this meant to be the case? In general, how do I get settings for the current canvas (obj is a TCanvas) and then update them? For example, I was able to get the logy from:

```js
const canvas = await draw(dom, obj)
const logY = canvas.getObject().fLogy;

```

but am not sure as to how I’d then update another canvas with this. For example, this is an idea I had, which didn’t work.

```js
Object.assign(canvas.getObject(), {fLogy: logY})

```

For further information, this is the code that creates the plot:

```py
npoints = data["num_entries"]

graph = ROOT.TGraph(npoints)

for i in range(npoints):
    t = data["timestamps"][i].timestamp()
    y = data["values"][i]
    graph.SetPoint(i, t, y)

c = ROOT.TCanvas("c", "Canvas", 800, 600)

graph.Draw("AP")

xaxis = graph.GetXaxis()
xaxis.SetTimeDisplay(1)
xaxis.SetTimeFormat("%Y-%m-%d %H:%M:%S")
xaxis.SetLabelSize(0.03)

c.Modified()
c.Update()

c.SaveAs(f'{output_file}')

```

Thanks in advance.

_ROOT Version:_ 6.32.08  
_Platform:_ macosxarm64  
_Compiler:_ Apple clang 16.0.0

* * *

---

<div class="post-metadata">

**Author:** ![devajith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/devajith/32/37165_2.png) [@devajith](https://root-forum.cern.ch/u/devajith)\
**Post date:** [April 1, 2025, 8:09am UTC](https://root-forum.cern.ch/t/how-to-redraw-preserving-axis-settings/63265/2 "2025-04-01T08:09:01Z")

</div>

Hi @frezzonico

Welcome to the ROOT forum and thanks for your question.

I’m adding @linev in the loop

---

<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:** [April 1, 2025, 8:12am UTC](https://root-forum.cern.ch/t/how-to-redraw-preserving-axis-settings/63265/3 "2025-04-01T08:12:41Z")

</div>

Hi,

If you are using TCanvas for drawing, log scale will be applied from the new instance of TCanvas in `JSROOT.redraw` call. It is possible to copy log scale attributes before calling `redraw` like:

```auto
const canv_painter = await draw(dom, obj);

...

new_obj.fLogy = canv_painter.getObject().fLogy;
await redraw(dom, new_object);

```

But you also can try to draw/redraw `TGraph` object. In such case `TCanvas` will be created and preserved by JSROOT - including log scale settings.

Regards,  
Sergey
