Gnuplot Epsuplot图形的水平放置

Gnuplot Epsuplot图形的水平放置,gnuplot,pdflatex,Gnuplot,Pdflatex,我使用gnuplot生成一个具有以下代码的绘图: set logscale y set xlabel "iteration" set ylabel "$\\varepsilon$" set terminal epslatex color size 3.5,3.5 set out 'l2_errors_with_iteration_cc=00001_dt=1200_test.tex' plot "l2_errors_with_iteration_cc=.00001_da

我使用gnuplot生成一个具有以下代码的绘图:

  set logscale y
  set xlabel "iteration"
  set ylabel "$\\varepsilon$"
  set terminal epslatex color  size 3.5,3.5
  set out 'l2_errors_with_iteration_cc=00001_dt=1200_test.tex'
  plot  "l2_errors_with_iteration_cc=.00001_damping=0.9_dt=0.1200.txt" using 1:2 title 'current' with lines lw 4
  set out
  quit
\documentclass[aps,showpacs,twocolumn,10pt,pra]{revtex4-1}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{float}
\begin{document}
\section{Introduction} \label{sec:Introduction}
\blindtext
\blindtext
\blindtext

\begin{figure}[H]
\centering
\input{l2_errors_with_iteration_cc=00001_dt=1200_test.tex}
\caption{Here we see the error plotted as a function of iteration.}%
\end{figure}

\end{document}
使用以下数据:

 0   2.03616944439
 0   2.03616944439
 2   0.25330118741
 3   0.22665346605
 4   0.20262719150
 5   0.18101252740
 6   0.16160551934
 7   0.14420900466
 8   0.12863525831
 9   0.11470804565
10   0.10226380345
11   0.09115208853
12   0.08123549251
13   0.07238919637
14   0.06450029952
15   0.05746702167
16   0.05119784692
17   0.04561065697
18   0.04063188453
19   0.03619570607
20   0.03224328518
21   0.02872207183
22   0.02558515939
23   0.02279069871
24   0.02030136683
25   0.01808388719
26   0.01610859780
27   0.01434906324
28   0.01278172704
29   0.01138560027
30   0.01014198331
31   0.00903421712
32   0.00804746131
33   0.00716849603
34   0.00638554533
35   0.00568811962
36   0.00506687532
37   0.00451348969
38   0.00402054934
39   0.00358145092
40   0.00319031255
41   0.00284189508
42   0.00253153177
43   0.00225506578
44   0.00200879445
45   0.00178941964
46   0.00159400355
47   0.00141992933
48   0.00126486603
49   0.00112673731
50   0.00100369368
51   0.00089408768
52   0.00079645182
53   0.00070947891
54   0.00063200454
55   0.00056299152
56   0.00050151594
57   0.00044675483
58   0.00039797511
59   0.00035452379
60   0.00031581922
61   0.00028134330
62   0.00025063454
63   0.00022328189
64   0.00019891921
65   0.00017722041
66   0.00015789505
67   0.00014068445
68   0.00012535825
69   0.00011171132
70   0.00009956099
71   0.00008874462
72   0.00007911742
73   0.00007055053
74   0.00006292926
75   0.00005615155
76   0.00005012662
77   0.00004477376
78   0.00004002118
79   0.00003580510
80   0.00003206884
81   0.00002876204
82   0.00002583994
83   0.00002326277
84   0.00002099512
85   0.00001900543
86   0.00001726544
87   0.00001574978
88   0.00001443551
89   0.00001330171
90   0.00001232920
91   0.00001150022
92   0.00001079827
93   0.00001020797
94   0.00000971499
95   0.00000930611
96   0.00000896921
97   0.00000869333
98   0.00000846870
99   0.00000828674
100   0.00000814002
101   0.00000802220
102   0.00000792792
103   0.00000785271
104   0.00000779289
105   0.00000774543
106   0.00000770786
107   0.00000767818
108   0.00000765479
109   0.00000763639
110   0.00000762194
111   0.00000761064
112   0.00000760180
113   0.00000759492
114   0.00000758957
115   0.00000758544
116   0.00000758225
117   0.00000757980
借助以下tex文件,它生成了一个非常好的绘图:

% GNUPLOT: LaTeX picture with Postscript
\begingroup
  \makeatletter
  \providecommand\color[2][]{%
    \GenericError{(gnuplot) \space\space\space\@spaces}{%
      Package color not loaded in conjunction with
      terminal option `colourtext'%
    }{See the gnuplot documentation for explanation.%
    }{Either use 'blacktext' in gnuplot or load the package
      color.sty in LaTeX.}%
    \renewcommand\color[2][]{}%
  }%
  \providecommand\includegraphics[2][]{%
    \GenericError{(gnuplot) \space\space\space\@spaces}{%
      Package graphicx or graphics not loaded%
    }{See the gnuplot documentation for explanation.%
    }{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
    \renewcommand\includegraphics[2][]{}%
  }%
  \providecommand\rotatebox[2]{#2}%
  \@ifundefined{ifGPcolor}{%
    \newif\ifGPcolor
    \GPcolortrue
  }{}%
  \@ifundefined{ifGPblacktext}{%
    \newif\ifGPblacktext
    \GPblacktexttrue
  }{}%
  % define a \g@addto@macro without @ in the name:
  \let\gplgaddtomacro\g@addto@macro
  % define empty templates for all commands taking text:
  \gdef\gplbacktext{}%
  \gdef\gplfronttext{}%
  \makeatother
  \ifGPblacktext
    % no textcolor at all
    \def\colorrgb#1{}%
    \def\colorgray#1{}%
  \else
    % gray or color?
    \ifGPcolor
      \def\colorrgb#1{\color[rgb]{#1}}%
      \def\colorgray#1{\color[gray]{#1}}%
      \expandafter\def\csname LTw\endcsname{\color{white}}%
      \expandafter\def\csname LTb\endcsname{\color{black}}%
      \expandafter\def\csname LTa\endcsname{\color{black}}%
      \expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
      \expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
      \expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
      \expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
      \expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
      \expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
      \expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
      \expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
      \expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
    \else
      % gray
      \def\colorrgb#1{\color{black}}%
      \def\colorgray#1{\color[gray]{#1}}%
      \expandafter\def\csname LTw\endcsname{\color{white}}%
      \expandafter\def\csname LTb\endcsname{\color{black}}%
      \expandafter\def\csname LTa\endcsname{\color{black}}%
      \expandafter\def\csname LT0\endcsname{\color{black}}%
      \expandafter\def\csname LT1\endcsname{\color{black}}%
      \expandafter\def\csname LT2\endcsname{\color{black}}%
      \expandafter\def\csname LT3\endcsname{\color{black}}%
      \expandafter\def\csname LT4\endcsname{\color{black}}%
      \expandafter\def\csname LT5\endcsname{\color{black}}%
      \expandafter\def\csname LT6\endcsname{\color{black}}%
      \expandafter\def\csname LT7\endcsname{\color{black}}%
      \expandafter\def\csname LT8\endcsname{\color{black}}%
    \fi
  \fi
  \setlength{\unitlength}{0.0500bp}%
  \begin{picture}(5040.00,5040.00)%
    \gplgaddtomacro\gplbacktext{%
      \csname LTb\endcsname%
      \put(1342,704){\makebox(0,0)[r]{\strut{} 1e-06}}%
      \put(1342,1286){\makebox(0,0)[r]{\strut{} 1e-05}}%
      \put(1342,1867){\makebox(0,0)[r]{\strut{} 0.0001}}%
      \put(1342,2449){\makebox(0,0)[r]{\strut{} 0.001}}%
      \put(1342,3030){\makebox(0,0)[r]{\strut{} 0.01}}%
      \put(1342,3612){\makebox(0,0)[r]{\strut{} 0.1}}%
      \put(1342,4193){\makebox(0,0)[r]{\strut{} 1}}%
      \put(1342,4775){\makebox(0,0)[r]{\strut{} 10}}%
      \put(1474,484){\makebox(0,0){\strut{} 0}}%
      \put(2002,484){\makebox(0,0){\strut{} 20}}%
      \put(2530,484){\makebox(0,0){\strut{} 40}}%
      \put(3059,484){\makebox(0,0){\strut{} 60}}%
      \put(3587,484){\makebox(0,0){\strut{} 80}}%
      \put(4115,484){\makebox(0,0){\strut{} 100}}%
      \put(4643,484){\makebox(0,0){\strut{} 120}}%
      \put(176,2739){\rotatebox{-270}{\makebox(0,0){\strut{}$\varepsilon$}}}%
      \put(3058,154){\makebox(0,0){\strut{}iteration}}%
    }%
    \gplgaddtomacro\gplfronttext{%
      \csname LTb\endcsname%
      \put(3656,4602){\makebox(0,0)[r]{\strut{}current}}%
    }%
    \gplbacktext
    \put(0,0){\includegraphics{l2_errors_with_iteration_cc=00001_dt=1200_test.pdf}}%
    \gplfronttext
  \end{picture}%
\endgroup
并使用以下代码生成我的文档:

  set logscale y
  set xlabel "iteration"
  set ylabel "$\\varepsilon$"
  set terminal epslatex color  size 3.5,3.5
  set out 'l2_errors_with_iteration_cc=00001_dt=1200_test.tex'
  plot  "l2_errors_with_iteration_cc=.00001_damping=0.9_dt=0.1200.txt" using 1:2 title 'current' with lines lw 4
  set out
  quit
\documentclass[aps,showpacs,twocolumn,10pt,pra]{revtex4-1}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{float}
\begin{document}
\section{Introduction} \label{sec:Introduction}
\blindtext
\blindtext
\blindtext

\begin{figure}[H]
\centering
\input{l2_errors_with_iteration_cc=00001_dt=1200_test.tex}
\caption{Here we see the error plotted as a function of iteration.}%
\end{figure}

\end{document}
现在,问题来了。在上面的代码中,我可以更改此行:

 \begin{picture}(5040.00,5040.00)%
  \put(176,2739){\rotatebox{-270}{\makebox(0,0){\strut{}$\varepsilon$}}}%
更具体地说是第一个数字,使其变大或变小。使其变小会将生成的图形向右移动。因此,使其变大应将图形向左移动。然而,事实并非如此。为什么?我想这样做,因为我认为在情节的左边有太多的空间,伊拉贝尔似乎很孤独。我可以通过更改此行将其移入:

 \begin{picture}(5040.00,5040.00)%
  \put(176,2739){\rotatebox{-270}{\makebox(0,0){\strut{}$\varepsilon$}}}%

将176增加(或减少)到我希望的任何值,但这并不能改变这样一个事实,即空间似乎比需要的大得多。有趣的是,增加或减少第二个5040.00-确实-实际上可以将绘图向上或向下移动到任何人喜欢的位置(就我测试的情况而言),这就是为什么我觉得这可能是一个bug。

通过复制您的图形,我发现左侧的空白太多是由于
gnuplot
文件中的y标签
\varepsilon
造成的

通过使用
gnuplot
命令偏移y标签,我可以复制一个位置良好的图形

set ylabel offset 3,0 "$\\varepsilon$"

gnuplot
文件中。您无需更改
begin{picture}
环境中的位置。

这将使
ylabel
向右移动,但不会消除空白问题。设置边距,例如在屏幕0.1设置lmargin,应该有助于填充gnuplot画布上的空白(本例中宽度为3.5英寸)。太棒了。Madhurjya的回答和Miguel的建议都会带来可接受的解决方案。然而,
在屏幕0.1设置lmargin
也需要在tex文件中重新定位varepsilon(可能还有其他方法(设置为-290)),因此Madhurjya的答案似乎需要更少的工作。谢谢你@你必须把两个答案结合起来。更改ylabel偏移和左侧边距。您应该避免更改TeX文件本身中的任何内容。对于大型TIC格式,也会发生同样的情况,请参见例如。Gnuplot无法正确确定LaTeX格式的标签位置和页边距。您是否也可以共享
set terminal epslatex
行?不确定您的意思。。我包括这一行
设置颜色大小3.5,3.5