Funny behavour of .eps file created interactively in cint

Hi, using root 5.17.03, made a canvas and saved it as .eps file, then I want to show it next to another canvas that I saved the same way, one of them is attached as a root file, and then I get the behavior shown in the attached .ps file. The .eps pic is shortly shown, but then disapears. In the .dvi with xdvi the same behavior is observed. When converted to .pdf, the left plot is just gone.

Any idea what is going on? I do it interactively to set the title by hand in the center, such a pain to do that by script. I think this is a bug, same procedure worked with previous root versions.

Hm, I don’t seem to be able to attach the .eps files. Maybe two attachments max. Anyway, something wrong. I fixed it now by opening the .eps files in the gimp, then it works, but I can’t keep the same nice resolution!

Cheers,

Ytsen.

Edit: Here is the .eps file: desy.de/~ytsen/tmp/canvas.2d … ll.ptx.eps
show.problem.ps (379 KB)
show.problem.root (23.2 KB)

I do not understand what you are doing. I see that the eps generated by latex has the “flashing behavior” you described when I visualize it using gv. But the file canvas.2d.smeared.all.ptx.eps is fine and when I generate an eps file from the ROOT file you attached it looks ok also.

Can you send a script, a macro etc … allowing me to redo all the steps you did to end up with that faulty show.problem.ps file ?

Thanks

Hi,

Here is what I am doing and I saved all the files here: desy.de/~ytsen/tmp/ there you find these files:

plot.faulty.eps.C
faulty.plot.eps
show.problem.aux
show.problem.dvi
show.problem.log
show.problem.ps
latex.output.txt
plot.lik.clean.output.not.smeared.all.12.20071005.root

  1. The “plot.faulty.eps.C” file I run as:

[h1paroia] /user/ytsen/epvec/plot $ root -l plot.faulty.eps.C
root [0]
Processing plot.faulty.eps.C…
Opened file plot.lik.clean.output.not.smeared.all.12.20071005.root

  1. Now the canvas comes up. I choose File->SaveAs…
    Then I change the file type to .eps and choose a file name, the file is made:

root [1] Info in TCanvas::Print: eps file /h1desy06/user/ytsen/epvec/plot/faulty.plot.eps has been created
root [1] .q

  1. Then I navigate to another directory, where I latex the file: “show.problem.tex”. The standard output is redirected, for the curious reader, to the file “latex.output.txt”. Also apply dvips.

  2. View with xdvi or gv. You will see that the first page is fine, where the plot is the only thing on the page. On the second page I want to show the picture next to itself. It looks like as if the canvas has a rather large size, much larger than the visible part of it and it covers up the neigbouring picture. I wonder if this is an artefact of root.

Cheers,

Ytsen.

Hi, someone here at H1 noted this:

Looking at the file there were (at least) two white backgrounds, one
huge one and a much smaller one sized at the bounding box.

desy.de/~sankey/canvas.2d.sm … .ptx.2.eps
has both of these removed.

Kind regards,

     Dave 

His removal of the huge background did remove the symptom.

Same thing in root 5.16.
Same thing also in 5.16 if I choose directly File->Save->canvas.eps, in stead of going over the File->SaveAs … option.

I see that big “bf” box in background in your EPS file. I will investigate why it is there in case of EPS file. It should not be seems to me. I will let you know.

I cannot run your macro. I get:

Processing plot.faulty.eps.C…
Opened file a.root
Error: illegal pointer to class object Get(“h2.cum.int.dk.l.12”) 0x0 3 plot.faulty.eps.C:57:
*** Interpreter error recovered ***

So I tried to generate an EPS file with the $ROOTSYS/tutorials/graphs/ graph.C macro.
I generated the EPS from Save->c1.eps . I modified the tex file as shown in the attachement and I get the attached eps which is correct.
My root version is 5.17/03
show.problem.ps (70.4 KB)

the tex file:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[tbp]
\includegraphics[width=\linewidth]{c1.eps}
\end{figure}

\clearpage

\begin{figure}[tbp]

  \begin{minipage}[t]{.49\linewidth}
    \par \vspace{0mm}
    \includegraphics[width=\linewidth]{c1.eps}
  \end{minipage}%
  \hfill
  \begin{minipage}[t]{.49\linewidth}
    \par \vspace{0mm}
    \includegraphics[width=\linewidth]{c1.eps}
  \end{minipage}\\
  \caption{\textit{68\% and 95\% CL limits on $d\kappa$ and $\lambda$.
    }}
  \label{limits.2d.all.and.12}
\end{figure}


\end{document}

Sorry, I forgot the attach. the root file you need for the macro, here it is:

desy.de/~ytsen/tmp/plot.lik. … 71005.root

This simplified version of your macro produces the right result:

{
   gStyle->SetCanvasColor(0);
   gStyle->SetFrameBorderMode(0);
   gStyle->SetTitleFillColor(0);   
   gStyle->SetOptStat(0);
   gStyle->SetOptFit(0);
   gStyle->SetTitleBorderSize(0);
   gStyle->SetFrameLineWidth(1);
   gStyle->SetPadBottomMargin(0.25);
   gStyle->SetPadLeftMargin(0.2);
   gStyle->SetPadRightMargin(0.15);
   gStyle->SetPadTopMargin(2);
   gStyle->SetLabelSize(0.05,"X");
   gStyle->SetLabelSize(0.05,"Y");
   gStyle->SetLabelOffset(0.01,"Y");
   gStyle->SetTickLength(0.04,"X");
   gStyle->SetTickLength(0.04,"Y");
   gStyle->SetTitleSize(0.1);
   gStyle->SetTitleSize(0.077,"X");
   gStyle->SetTitleSize(0.085,"Y");
   gStyle->SetTitleOffset(.9, "X");
   gStyle->SetTitleOffset(1., "Y");
   
   TFile * f = new TFile("a.root", "READ");

   Int_t colors[] = {7, 5,10};  
   Double_t levels[] = {0., .68, .95}; 
   gStyle->SetPalette(3,colors);

   TFile * fsmall = new TFile("a.root","READ");

   TCanvas * c1 = new TCanvas("c1","c1", 500, 500, 500, 500);   
   c1->SetGridx();
   c1->SetGridy();

   TH2F * h2sm12 = (TH2F*) fsmall->Get("h2.cum.int.dk.l.12")->Clone();
   h2sm12->SetFillColor(0);
   h2sm12->SetContour(3,levels);
   h2sm12->SetTitle("Confidence Level;P_{T} > 12 GeV       d#kappa; #lambda");
   h2sm12->Draw("cont4z");    
}

Hm, indeed it does. So … what was the problem? I still don’t understand it. I suppose you could reproduce the funny behaviour?

Yes I could because I was able to fix it. That was due the the temporary histogram you created and plotted on top with option same. That combination made that huge box. Seems to me it was not necessary to make the macro that complex so I simplified it. So unless you really need what you had before I guess you can use what I do in the new version.

Thank you! I understand and can avoid this phenomenon now :slight_smile:

Cheers,

Ytsen.

PS. To whom it concerns: This is of course a bug because unwanted behavior. The only reason I think this, is that the resulting .eps file does not correspond to what is presented inside the canvas.

Indeed you get what is displayed on the screen even with your macro. If you print the file or vizualize it using gv it looks as good as on the screen. But even on the screen you have this big box hidden somewhere. It only appears in some particular context ie: when you include it the way you did in Latex. ROOT being a script oriented system it is very easy to do all kind of things not initially foressen. In your particular case the initial macro was far to complex for what it was doing. That’ s why I asked you if you really need to be done that way. But I will have a look at the initial macro to understand from where the big box come and I will then judge if it requires some fix or not.