Graphics, Figures & Tablesgnuplottex bounding box

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

gnuplottex bounding box

Post by nico »

Hello,

I use gnuplottex in my document to plot data. But the resulting figure is moved to the right. I want it to be left like the caption. Please see the attachment.

Here is my code:

Code: Select all

\documentclass[10pt,a4paper,captions=nooneline]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{gnuplottex}
\usepackage{subfig}
\begin{document}

\begin{figure}
    \subfloat[test1]{\input{./graph}}
    \subfloat[test2]{\input{./graph}}
\end{figure}

\end{document}
And this is graph.tex:

Code: Select all

\label{fig:test} 
\begin{gnuplot}[terminal=pdf,scale=0.8,terminaloptions={size 3in, 2in}] 
    set size ratio 1 
    plot sin(x) 
\end{gnuplot} 
I read that i could be a problem with the bounding box. I found only solutions for eps files, but not for included code. Could someone help me?

Edit: I use gnuplot version 4.4.
Attachments
tst.pdf
output
(31.2 KiB) Downloaded 358 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: gnuplottex bounding box

Post by localghost »

I seem to see a contradiction between the settings for your plots. On the one hand you set the plot size via the »termnialoptions« key to 3in×2in. On the other hand you declare the size ratio to 1 in the script file itself. That means that the actual plot will be sized as 2in×2in but there will be a total space of 3in×2in reserved. This seems to cause the additional white space on the left of each plot. I suggest to adjust that either by using appropriate values in both settings or just using only one single setting.


Best regards
Thorsten
nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

Re: gnuplottex bounding box

Post by nico »

Hi Thorsten,

sadly this is not the solution. First I didn't have the terminaloptions for the size. I added them during my attempts to solve the problem. Thanks anyway.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

gnuplottex bounding box

Post by gmedina »

Hi,

why don't you use pgfplotsdirectly? A little example:

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{subfig}
\usepackage{pgfplots}

\pgfplotsset{width=.9\textwidth,compat=newest}

\begin{document}

\begin{figure}[!ht]
  \centering
  \subfloat[]{
  \begin{tikzpicture}[scale=0.6]
  \begin{axis}[%
    axis background/.style={fill=yellow!10},
  ]
  \addplot[domain=-pi:pi,samples=100,green] {sin(deg(2*x))};
{sin(deg(3*x))/x};
  \end{axis}
  \end{tikzpicture}}
  \subfloat[]{
  \begin{tikzpicture}[scale=0.6]
  \begin{axis}[%
    axis background/.style={fill=yellow!10},
  ]
  \addplot[domain=-pi:pi,samples=100,blue] {sin(deg(x))};
{sin(deg(3*x))/x};
  \end{axis}
  \end{tikzpicture}}
  \caption{Test figure with \texttt{pgfplots}.}
\end{figure}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

gnuplottex bounding box

Post by nico »

Hello gmedina,

I allready tried pgfplots. The matter is, that the data files I am plotting are really big. I have 100.000 lines there and i need 36 graphs. Even if I extent the memory, it takes a while. I killed the pdflatex process after 20 minutes (with gnuplot i need less than 1 minute).

I also read that, one can parse gnuplot through pgfplot. But, if I understood right, this is only for mathematical terms. Gnuplot calculates the data and pgfplots draws it. So this should also be no solution for me.

Also I had a look at pst-plot. But I didn't get the graph scaled exactly. And this is just too much work for so many diagrams. Specially when I experiment with parameters.

But thank you for your effort with the example, gmedina!!

At the Moment I use a workaround. I am not really sattisfied, but it could probably help others:

First I create gnuplot-srcipts like this:
b_cB1.plt

Code: Select all

reset
set terminal postscript eps enhanced color
set output "b_cB1.eps"
set xlabel "t [d]"
set ylabel "c [kg/m^3]"
set autoscale
set key bottom left
plot  'b1.csv' using 1:6 with lines title "1. Ordnung" lw 3 lt 1 smooth csplines
Then I use a Script to create eps and mps files. On my Ubuntu 10.04 I need texlive-metapost and pstoedit packages.

Code: Select all

#!/bin/bash
gnuplot *.plt  # batch convert all gnuplot scripts in this folder

for i in *.eps  # convert eps to mps
do
i=$(basename $i .eps)
pstoedit -f mpost -fontmap /usr/share/pstoedit/mpost.fmp $i.eps tmp-file.mp
mpost tmp-file.mp
mv tmp-file.1 $i.mps
rm -f tmp-file.mp tmp-file.log
done

mv *.mps ./mps/  # move all mps files to folder mps
mv *.eps ./eps/  # move all eps files to folder eps
rm *~  # remove the temporary files 
Then i can simply include the graphics in pdflatex by using \includegraphics{./inc/Diagramme/b_cG2}. The bounding box is fine and subfigure works.

Anyway...I am still thankfull, if someone has a better idea to include the graph code directly in pdflatex!
Post Reply