\groupplot의 플롯을 어떻게 수평 및 수직으로 이동할 수 있습니까?

\groupplot의 플롯을 어떻게 수평 및 수직으로 이동할 수 있습니까?

이것은 내 코드입니다.

\documentclass[tikz,12pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{mathptmx}    
\usetikzlibrary{pgfplots.groupplots}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}

\usepackage{filecontents}
\begin{filecontents}{1.csv}
400 0.02
450 0.03
500 0.035
550 0.08
600 0.1
650 0.05
700 0.15
750 0.12
800 0.02
850 0.05
900 0.1
\end{filecontents}
\begin{filecontents}{2.csv}
1   0.02
2   0.03
3 0.035
4   0.08
5   0.1
6 0.05
7   0.15
8 0.12
9   0.02
10  0.05
11  0.1
\end{filecontents}

\begin{document}
\pgfplotsset{every axis/.append style={
line width=.5 pt,
tick style={line width=.6pt}}}
\begin{tikzpicture}
\begin{groupplot}[group style={
        group size=2 by 1,
        vertical sep=-10cm,
        horizontal sep=-8.5cm,
    },]    
\nextgroupplot[
height=10cm,
xmin=400,
ymax=0.2,
enlarge x limits=.0,
enlarge y limits=.02,
ylabel={Absorption, A.U.},
xlabel={Wavelength, nm},
minor x tick num=4,
minor y tick num=4,
tick label style={/pgf/number format/fixed},
%xtick={200, 220, ...,360},
legend style={legend pos=north west,legend cell align=left,font=\tiny,draw=none,text height=0.1em},
]

\addplot[green] table [x index=0,y index=1] {1.csv};

\nextgroupplot[
font=\tiny,
height=5cm,
width=4cm,
ymax=0.12,
enlarge x limits=.0,
enlarge y limits=.02,
ylabel={Absorption at 740\,nm, A.U.},
xlabel={pH},
x label style={at={(axis description cs:0.5,-.05)},anchor=north},
y label style={at={(axis description cs:-0.2,.5)},anchor=south},
tick label style={/pgf/number format/fixed},
minor x tick num=4,
minor y tick num=4,
%xtick={200, 220, ...,360},
legend style={legend pos=north west,legend cell align=left,font=\tiny,draw=none,text height=0.1em},
]
\addplot[black,mark=*,dashed,line width=0.5pt] table [x index=0,y index=1] {2.csv};
\end{groupplot}
\end{tikzpicture}

\end{document}

이것이 내가 가진 것입니다:

여기에 이미지 설명을 입력하세요

내 하위 플롯을 위로 이동하고 싶습니다. 어떻게 할 수 있습니까? groupplot내가하려는 일을 수행하는 다른 방법을 사용해야합니까 ?

답변1

내 생각에는 groupplots실제로 이런 종류의 작업을 위한 것이 아닙니다. 대신 두 가지 환경을 사용하는 것이 좋습니다 axis. 또는 좌표계 \coordinate를 사용하여 더 큰 축에 a를 배치하고 이 좌표에 더 작은 축을 배치합니다.rel axis csaxis cs

아래 코드에서 볼 수 있습니다.

\coordinate (otheraxis) at (rel axis cs:0.15,0.5);

첫 번째 축 axis과 두 번째 축에 대한 옵션에서

at={(otheraxis)},

axis의 왼쪽 하단 모서리를 배치합니다 otheraxis. 이렇게 하면 좌표를 수정하여 더 작은 축을 쉽게 이동할 수 있습니다 otheraxis.

\documentclass[tikz,12pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{mathptmx}    
\usetikzlibrary{pgfplots.groupplots}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}

\usepackage{filecontents}
\begin{filecontents}{1.csv}
400 0.02
450 0.03
500 0.035
550 0.08
600 0.1
650 0.05
700 0.15
750 0.12
800 0.02
850 0.05
900 0.1
\end{filecontents}
\begin{filecontents}{2.csv}
1   0.02
2   0.03
3 0.035
4   0.08
5   0.1
6 0.05
7   0.15
8 0.12
9   0.02
10  0.05
11  0.1
\end{filecontents}

\begin{document}
\pgfplotsset{every axis/.append style={
line width=.5 pt,
tick style={line width=.6pt}}}

\begin{tikzpicture}
\begin{axis}[
height=10cm,
xmin=400,
ymax=0.2,
enlarge x limits=.0,
enlarge y limits=.02,
ylabel={Absorption, A.U.},
xlabel={Wavelength, nm},
minor x tick num=4,
minor y tick num=4,
tick label style={/pgf/number format/fixed},
%xtick={200, 220, ...,360},
legend style={legend pos=north west,legend cell align=left,font=\tiny,draw=none,text height=0.1em},
]

\addplot[green] table [x index=0,y index=1] {1.csv};

\coordinate (otheraxis) at (rel axis cs:0.15,0.5);
\fill [red] (otheraxis) circle[radius=3pt];
\end{axis}

\begin{axis}[
at={(otheraxis)},
font=\tiny,
height=5cm,
width=4cm,
ymax=0.12,
enlarge x limits=.0,
enlarge y limits=.02,
ylabel={Absorption at 740\,nm, A.U.},
xlabel={pH},
x label style={at={(axis description cs:0.5,-.05)},anchor=north},
y label style={at={(axis description cs:-0.2,.5)},anchor=south},
tick label style={/pgf/number format/fixed},
minor x tick num=4,
minor y tick num=4,
%xtick={200, 220, ...,360},
legend style={legend pos=north west,legend cell align=left,font=\tiny,draw=none,text height=0.1em},
]
\addplot[black,mark=*,dashed,line width=0.5pt] table [x index=0,y index=1] {2.csv};
\end{axis}
\end{tikzpicture}

\end{document}

관련 정보