# Better way of embedding OpenOffice plots into LaTeX?

Right now, I create plots in the spreadsheet, copy them to OpenOffice Draw, save as images, and then put them (as images) into my .tex file.

But that leads to problems with resolution (labels too big/small), difficulties to change the graph when data changes, etc.

Is there some better way to do it?

-

If you need to plot a series of points in the spreadsheet you could use the pgfplots packet. First of all export your data as a csv file (Comma Separated Values). Then you can easily plot the points, I made a small example for you:

\begin{figure}[h!]
\centering

\begin{tikzpicture}
%
%% NB: Declare logarithmic axis
\begin{loglogaxis}[
% Labels for the axis
xlabel=Dof,
ylabel=$L_2$ error]
%
%% in the options you select the columns to be used as data sources
\end{loglogaxis}
\end{tikzpicture}
\end{figure}


This produces as output:

and this is the original data:

# Convergence results
# fictional source, generated 2008
1,4,2.50000000e-01,7.57858283e-01,48,0,0
2,16,6.25000000e-02,5.00000000e-01,25,-3.00000000e-01,4
3,64,1.56250000e-02,2.87174589e-01,41,-3.99999999e-01,4
4,256,3.90625000e-03,1.43587294e-01,8,-5.00000003e-01,4
5,1024,9.76562500e-04,4.41941738e-02,22,-8.49999999e-01,4
6,4096,2.44140625e-04,1.69802322e-02,46,-6.90000001e-01,4
7,16384,6.10351562e-05,8.20091159e-03,40,-5.24999999e-01,4
8,65536,1.52587891e-05,3.90625000e-03,48,-5.35000000e-01,3.99999999e+00
9,262144,3.81469727e-06,1.95312500e-03,33,-5.00000000e-01,4.00000001e+00
10,1048576,9.53674316e-07,9.76562500e-04,2,-5.00000000e-01,4.00000001e+00

-
That example is pretty, but can pdfplots plot all those graphs that OpenOffice can? –  Rogach May 2 '12 at 10:23
You can take a look at the manual, I would say you can plot basically anything. iro.umontreal.ca/~simardr/pgfplots.pdf –  Edo May 2 '12 at 10:28

You mean you save it as a raster graphic (PNG or, iih, JPG)? You shouldn't do that. Make a PDF out of it, which should be possible with Open Office out-of-the-box. You need the diagram on a page of it's own, or better in a document of its own. Then use pdfcrop on the PDF to crop the white space around the image and include it as PDF image using \includegraphics. This will work fine with pdflatex, xelatex and lualatex. For DVI mode (latex) you can convert the PDF to EPS using several tools.

Using this way the graphic will be a vector graphic and you don't have any issues with resolution.

-
OpenOffice can do this by default, but (at least on 3.4) it requires manually setting the page size to that of the graph; its very difficult to get the measurement perfect. I abandoned my effort with OO.org and PDF export and just used R instead. –  new123456 May 2 '12 at 11:15
@new123456: Using pdfcrop afterwards should remove all white space. –  Martin Scharrer May 2 '12 at 12:34