Open linev opened 1 year ago
I'll check. Thanks for the report
I am not sure how to reproduce this issue. I did the following: 1) run the macro Bessel.C 2) Save the canvas to a root file 3) reopen root with that saved file and display the canvas => The plots are exactly the same as when I execute the macro directly
Try to store canvas from tutorials/graphs/annotation3d.C
macro.
It modifies axes properties in the macro itself - like title or some special labels.
You can do same with Bessel.C
- but interactively before storing canvas to ROOT file
I see that with annotation3d.C
the changed labels are not stored in the canvas when it is displayed back. But it has nothing to do with DrawCopy
because this macro uses only Draw
.
Saving it as .C
also doesn't work.
TF1::DrawCopy
not used in tutorials.
But if one modifies any of such tutorials and will try to use - it will fail.
It fails already now. I am preparing a PR for the .C
case first ...
This one fixes the .C part: https://github.com/root-project/root/pull/13228
Now we have:
auto f = new TF1("x","x",-1,1);
f->Draw();
f->GetXaxis()->ChangeLabel(5, -1, -1, -1, -1, -1,"CHANGED");
c1->SaveAs("c1.C");
c1->SaveAs("c1.root");
The changed label is saved in the .C file but not in the root file.
Indeed TF1
the data member fHistogram
is not persistent (see TF1.h
) this member holds the axis. Therefore the axis are not persistent too and not saved in the root file. That's a design choice to not make fHistogram
persistent. I do not think that can be changed.
Therefore the axis are not persistent too and not saved in the root file.
Olivier, TF1::DrawCopy
is not about storage in the ROOT file.
It missing copying of histogram properties.
@lmoneta . In this issue Serguei points out the fact that TF1::DrawCopy
does not keep the axis labels and titles changes. This is normal because they are stored in the underlying histogram fHistogram
and this histogram is explicitly not copied . Is there a reason behind this ? . Does it make sense to copy also the underlying histogram ?
@lmoneta , I am just reviving this issue since perhaps the question of @couet got lost.
this histogram is explicitly not copied . Is there a reason behind this ? . Does it make sense to copy also the underlying histogram ?
I guess it was to avoid a memory leak: https://github.com/root-project/root/commit/c9e326e0dbebb4af52b58bfa3e73e80fb1f97682
If TF1::DrawCopy() is used to draw the function, all axis settings (which are stored in histogram) are lost.
A workaround would be to call: TF1::Clone(); TF1::Draw();
which does copy the underlying histogram.
@couet is this fixed? Can the item be closed?
No, issue is still there.
As mentioned - tutorials/math/Bessel.C
configures x axis title, but it does not appeared when TF1::DrawCopy()
is called.
@couet @linev is this still a problem? If yes, what is the plan to fix this?
Yes, issue is still there. One need to fix TF1::DrawCopy()
Check duplicate issues.
Description
If TF1::DrawCopy() is used to draw the function, all axis settings (which are stored in histogram) are lost.
Reproducer
This happens for instance in
tutorials/math/Bessel.C
macro where configured axis titles are not displayed.ROOT version
master and all recent releases
Installation method
build from source
Operating system
OpenSUSE Linux
Additional context
No response