I noticed since quite some time, that there seem to be some bugs in saving a canvas to a C macro. I attached two pictures to show what I found:
The upper plot shows the original canvas stored as .png, the lower plot shows the .png stored after re-running the .C macro exported from the original canvas. The bugs are
a) The TLegend is not rebuild correctly. The problem obviously is in the code fragment
TLegendEntry *entry=leg->AddEntry("","entry 1","PL"); entry->SetLineColor(2); entry->SetLineStyle(1); ... entry=leg->AddEntry("","entry 2","PL"); entry->SetLineColor(4); ...
Replacing the new assignment to the existing pointer
entry with a completely new TLegendEntry (like
TLegendEntry *entry2 ...) doesn’t fix the problem. Using
entry=leg->AddEntry(graph,"entry 2","PL"); does, but since the pointer
graph is also used multiple times, in only fixes the problem for the last entry. This issue is pretty nasty in case you have many graphs and need to fix everything by hand afterwards.
b) Not so obviously to be noticed, the size of the canvas recreated by the .C macro is larger in height than the original one (in this case by 20 pixels). The reason seems to be that in the original canvas the event status bar is shown, in the re-created one it is not, but both windows have the same size. This enlarges the effective area of the re-created canvas by the area of the status bar.
ROOT Version: 6.16/00
Platform: Not Provided
Compiler: Not Provided