Plot mode similar to gnuplot's epslatex

In fact what you are requesting is

canvas.Print("canvas.tex"); that will generate a “canvas.tex” file with all text and image scaling instructions and an associated “canvas.eps” file with the dumb graphics.

Olivier, one more thing for your todo list.

Rene

[quote=“brun”]In fact what you are requesting is

canvas.Print("canvas.tex");
that will generate a “canvas.tex” file with all text and image scaling instructions and an associated “canvas.eps” file with the dumb graphics.

Olivier, one more thing for your todo list.
[/quote]
Yes, this is exactly what I had in mind. It would be great to have this print mode.

Thanks for the consideration,
Frank

So that means all the text (axis labels, axis title, legend etc …) clearly written in ASCII in a Latex file and all the rest (line etc) in EPS ? and you want the EPS aligned on the text ?

If that is really what you want that is not easy at all to do, even impossible I guess, because it depends on the context of the latex document in which it will be included and because Latex is a text processing program and you cannot place items at pixel positions like in EPS. I guess with this “2 files approach” you can may be generate a caption corresponding to the histogram title but for all other texts (axis label in particular) that will be a nightmare and the result will never be perfect. Also what do you do when you have a divided pad ? you generate one EPS file per sub-pad and then try to align them on a grid in LaTex ?

In the old days, in PAW, was implemented a LaTex driver which generated one single LaTex file for that purpose. The author of that code had implemented a complete driver to generate ALL graphics in latex just because it is impossible to align all text on the EPS file(s). Even the lines, polygons etc were generated in LaTex. So the text looked good but the pure graphics was far to have the EPS quality and some graphics was not rendered at all (hatches etc …).

couet: Yes, this is exactly what I was trying to describe. It must be possible, because gnuplot is doing it. Of course you have to assume that in the document the eps figure does not get included scaled in respect to the latex text. But this can easily be avoided by scaling them both together with a \scalebox{} around them.

By the way: It is not only the text that is included in the latex file, but also the \includegraphics{file.eps} command. That way you then input the plot into your document: \input{file.tex} instead of the \includegraphics{file.eps} that you would usually do.

Please tell me if you would like me to attach the .eps and .tex for an example plot.

yes please put some attachement produced by gnuplot.

Ok, here it goes. Should compile with “latex document.tex”.
epslatex.tar.gz (26.5 KB)

Ok I see the result. Yes all the text is rendered wih latex. I confirm it is not a trivial task to implement that. I can only put it on our wish list for the time being.

I realise this is a very old post, but I think it is still relevant and would be a fantastic additions. I use the epslatex output from gnuplot often, and I feel a little let down when I can’t do make these simple outputs with root. Even though this isn’t such a simple addition, surely it would be worth it? Is there any update?

Cheers,
Liam

Nothing new on that.

I use a workaround for plotting with gnuplot to eps inside a ROOT script.

I create a text file with the parameter plots in gnuplot, called "mygraph.plt"
It contains for example:
set terminal epslatex color (or alternatively: set terminal postscript enhanced color)
set output "filename.eps"
plot x, "data.txt"
q

I assume every file is in the same folder as the script.

Then, in a ROOT script, I tell ROOT to execute gnuplot with this file, with a curious sentence:
if(system(“gnuplot mygraph.plt”))
{
cout << “Correctly plotted with gnuplot\n”;
}
else
{
cout << “error\n”;
}

Optionally, the same if you want to convert from epstopdf (this time without verbosity-error messages):
if (system(“epstopdf Porcentajes_LYSO_Ecut.eps”)){}

Other alternatives: create a string s=“gnuplot …” with the sentence, and type gSystem->Exec(s);

This way, you avoid creating the plot in gnuplot manually after you have obtained some data results in ROOT.

Has the status of this request changed? I would also appreciate this functionality.

It’s already working:

root.cern.ch/drupal/content/saving-canvas-tex
root.cern.ch/root/htmldoc/TTeXDump.html

AFAIK it’s in version 5.34.10.

Jean-François

Yes it is in 5.34 and beyond…

Thanks, it seems to work fairly well. I still have some issues with writing latex code into the axis labels, but I will open another thread for that.

Have you done it ? I do not see it …

I haven’t had the time yet to make screenshots. I will post the link to the new thread here. Thanks for your interest.

If they are bugs, submit them in Jira please.

I’m not sure if it is a bug or just ignorance of the syntax. I will try to post screenshots today.

Ok

I posted a description of the issue I am having with TLatex in titles and tex output. [url]Latex in Histogram Titles