1

I want to at my legend using tikz environment on top of my figures generated with gnuplot. I am happy with the result when I comment the part \node[anchor=center, text width=0.39cm, xshift=0cm, yshift=0cm] at (-6.0,1.0) {$sin(x)$};. My figure is fitting nicely to the pdf document but it has no legend (I do not want to create my legend with gnuplot).

However with this line my figure is shifting to the right of the pdf. It cause an empty space on the left side of my picture. I realize its size is changing when I move the \node to the different negative positions on x direction. I think, I am missing something trivial about the size of the \node. And ideas? Should I use \draw instead of \node?

Ps: I tried to put gnuplot part of my code into the another \node to be sure everything is on the same coordinate system which did not help my problem.

My present work is;

\documentclass[12pt]{standalone}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{gnuplot-lua-tikz}
\usepackage[shell]{gnuplottex}
\thispagestyle{empty}
\begin{document}

\begin{tikzpicture}
  \begin{gnuplot}[terminal=tikz,terminaloptions={size 14cm, 8cm}] 
     plot sin(x) w lines notitle
  \end{gnuplot}

  %I do not have any blank area without following line
  \node[anchor=center, text width=0.39cm, xshift=0cm, yshift=0cm] at (-6.0,1.0) {$sin(x)$}; 
  \end{tikzpicture}

\end{document}

Result with a huge blank part on the left: enter image description here

  • 1
    Welcome to TeX.SX! The node is included in the bounding box, try setting an explicit bounding box. – Andrew Swann Sep 16 '14 at 9:37
  • @trblnc_dsg Out of curiosity: What changes, if you add the option terminaloptions={nopicenvironment size 14cm, 8cm}? – John Oct 14 '14 at 17:10
  • @John with terminaloptions={nopicenvironment size 14cm, 8cm}, blank part still there. Looks like reference coordinates are changed somehow, cause position of the sin(x) by itself. – trblnc Oct 15 '14 at 7:58
  • @trblnc_dsg Hm okay. I think a solution using gnuplottex would be the following: Use the patch from sourceforge.net/p/gnuplot/feature-requests/409 on gnuplot-lua-tikz.lua, then use set label center "" at graph 0.5,0.1 font ',gp refnode,name=mynode1' and use \node[anchor=center, text width=0.39cm, xshift=0cm, yshift=0cm] at (mynode1) {$sin(x)$}; – John Oct 15 '14 at 9:35
2

Working example without the problem mentioned above, using explicit bounding box as recommended by @Andrew Swann;

\documentclass[12pt]{standalone}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{gnuplot-lua-tikz}
\usepackage[shell]{gnuplottex}
\thispagestyle{empty}
\begin{document}

\begin{tikzpicture}
  \draw [draw=none,use as bounding box] (0cm,0cm) rectangle (14cm,8cm);{
    \begin{gnuplot}[terminal=tikz,terminaloptions={size 14cm, 8cm}] 
      plot sin(x) w lines notitle
    \end{gnuplot}
  };

  \node[draw=none, text width=1cm] at (-5.0,1.0) {$sin(x)$}; 
\end{tikzpicture}

\end{document}

Also have a look for alternative method: Clipping

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.