[Tex/LaTex] How to set TikZ figure size and font size to match the doc

gnuplotlyxtikz-pgf

After some configuration nightmare i've managed to print out GNU Octave plots (via gnuplot) to tikz-pgf and display it in my LyX document..

%& -shell-escape -enable-write18

\documentclass{article}

\usepackage{tikz}
\usepackage{gnuplot-lua-tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\begin{tikzpicture}[gnuplot, scale = 1]

%% generated with GNUPLOT 4.6p0 (Lua 5.1; terminal rev. 99, script rev. 100)
%% Sun Jun 10 03:14:21 2012
\path (0.000,0.000) rectangle (8.000,6.000);
\gpcolor{color=gp lt color border}
\gpsetlinetype{gp lt border}
\gpsetlinewidth{0.50}
\draw[gp path] (1.012,0.985)--(1.263,0.985);
\draw[gp path] (7.447,0.985)--(7.196,0.985);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,0.985) {0};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,1.759)--(1.263,1.759);
\draw[gp path] (7.447,1.759)--(7.196,1.759);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,1.759) {0.5};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,2.534)--(1.263,2.534);
\draw[gp path] (7.447,2.534)--(7.196,2.534);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,2.534) {1};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,3.308)--(1.263,3.308);
\draw[gp path] (7.447,3.308)--(7.196,3.308);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,3.308) {1.5};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,4.082)--(1.263,4.082);
\draw[gp path] (7.447,4.082)--(7.196,4.082);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,4.082) {2};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,4.857)--(1.263,4.857);
\draw[gp path] (7.447,4.857)--(7.196,4.857);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,4.857) {2.5};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,5.631)--(1.263,5.631);
\draw[gp path] (7.447,5.631)--(7.196,5.631);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node right,font={\fontsize{10pt}{12pt}\selectfont}] at (0.828,5.631) {3};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,0.985)--(1.012,1.236);
\draw[gp path] (1.012,5.631)--(1.012,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (1.012,0.677) {0};
\gpcolor{color=gp lt color border}
\draw[gp path] (2.085,0.985)--(2.085,1.236);
\draw[gp path] (2.085,5.631)--(2.085,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (2.085,0.677) {0.5};
\gpcolor{color=gp lt color border}
\draw[gp path] (3.157,0.985)--(3.157,1.236);
\draw[gp path] (3.157,5.631)--(3.157,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (3.157,0.677) {1};
\gpcolor{color=gp lt color border}
\draw[gp path] (4.230,0.985)--(4.230,1.236);
\draw[gp path] (4.230,5.631)--(4.230,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (4.230,0.677) {1.5};
\gpcolor{color=gp lt color border}
\draw[gp path] (5.302,0.985)--(5.302,1.236);
\draw[gp path] (5.302,5.631)--(5.302,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (5.302,0.677) {2};
\gpcolor{color=gp lt color border}
\draw[gp path] (6.375,0.985)--(6.375,1.236);
\draw[gp path] (6.375,5.631)--(6.375,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (6.375,0.677) {2.5};
\gpcolor{color=gp lt color border}
\draw[gp path] (7.447,0.985)--(7.447,1.236);
\draw[gp path] (7.447,5.631)--(7.447,5.380);
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{10pt}{12pt}\selectfont}] at (7.447,0.677) {3};
\gpcolor{color=gp lt color border}
\draw[gp path] (1.012,5.631)--(1.012,0.985)--(7.447,0.985)--(7.447,5.631)--cycle;
\gpcolor{rgb color={0.000,0.000,0.000}}
\node[gp node center,font={\fontsize{12pt}{12pt}\selectfont}] at (4.229,0.215) {$\partial$};
\gpcolor{rgb color={0.000,0.000,1.000}}
\gpsetlinetype{gp lt plot 0}
\draw[gp path] (1.012,0.985)--(1.227,1.140)--(1.441,1.295)--(1.656,1.450)--(1.870,1.604)%
  --(2.085,1.759)--(2.299,1.914)--(2.514,2.069)--(2.728,2.224)--(2.943,2.379)--(3.157,2.534)%
  --(3.372,2.689)--(3.586,2.843)--(3.801,2.998)--(4.015,3.153)--(4.230,3.308)--(4.444,3.463)%
  --(4.659,3.618)--(4.873,3.773)--(5.088,3.927)--(5.302,4.082)--(5.517,4.237)--(5.731,4.392)%
  --(5.946,4.547)--(6.160,4.702)--(6.375,4.857)--(6.589,5.012)--(6.804,5.166)--(7.018,5.321)%
  --(7.233,5.476)--(7.447,5.631);
%% coordinates of the plot area
\gpdefrectangularnode{gp plot 1}{\pgfpoint{1.012cm}{0.985cm}}{\pgfpoint{7.447cm}{5.631cm}}
\end{tikzpicture}
%% gnuplot variables


\end{document}

enter image description here

Now I have two questions:

  • How to scale the whole image, such that it's width matches my LyX text width?
  • How to set the figure's font size in terms of multiples of the LyX text font size?

Help is much appreciated.

Best Answer

you can try this

\documentclass{article}

\usepackage{tikz}
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\noindent\begin{tikzpicture}[ xscale = \textwidth/8cm]
\path[draw] (0.000,0.000) rectangle (8.000,6.000);

\end{tikzpicture}

\lipsum[1]

\end{document}

enter image description here