我遇到了与 TSGM 相同的问题:pgfplots 中的轴断裂
我想在图中断开 y 轴。我尝试了 Michi 建议的解决方案pgfplots 中的轴断裂。
对我来说,它工作得很好,除了一个小问题:
我创建的图占据了整整一页,并且图下方没有标题。图周围的框非常长:
我使用下面的代码来创建情节:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\begin{document}
\pgfplotsset{
every non boxed x axis/.style={}
}
\fbox{
\begin{tikzpicture}[scale=1.0]
\begin{groupplot}[
scaled ticks=false,
group style={
group name=my fancy plots,
group size=1 by 2,
xticklabels at=edge bottom,
vertical sep=0pt
},
legend cell align=left,
legend pos=north west,
legend style = {font=\footnotesize},
width = 0.9\linewidth,
xtick=\empty,
yticklabel={\footnotesize ~\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\%}
]
\nextgroupplot[ymin=0.95,ymax=1.05,
ytick={1},
axis x line=top,
axis y discontinuity=parallel,
height = 0.3\linewidth,
]
\addplot+[no marks,
mark options={fill=black, color = black},
color = black,
mark size = 1] table
{data1.dat};
\addplot+[only marks,
color = blue,
mark = *,
mark options={fill=blue},
mark size = 1.5,
error bars/.cd,
error bar style={color=blue},
y dir = both,
y explicit,
x dir = none] table[x index={0},y index={1}, y error plus index ={2}, y error minus index ={3}]{data2.dat};
\legend{~R,~TRC}
\nextgroupplot[ymin=-0.005, ymax=0.015,
ytick={0,0.01},
axis x line=bottom,
ylabel={\qquad\footnotesize Anzahl der Dissecting-Kanten},
xlabel={\footnotesize Testinstanzen},
height = 0.4\linewidth,
]
\addplot+[no marks,
mark options={fill=black, color = black},
color = black,
mark size = 1] table{data1.dat};
\addplot+[only marks,
color = blue,
mark = *,
mark options={fill=blue},
mark size = 1.5,
error bars/.cd,
error bar style={color=blue},
y dir = both,
y explicit,
x dir = none] table[x index={0},y index={1}, y error plus index ={2}, y error minus index ={3}]{data2.dat};
\end{groupplot}
\end{tikzpicture}
}
\end{document}
有人知道这个问题吗?我非常感谢你的帮助!:)
干杯,
亚历克斯
一些示例数据文件:
数据1.dat:
0 1.000000
1 1.000000
2 1.000000
3 1.000000
4 1.000000
数据2.dat:
0 0.0056 0.0045 0.0044
1 0.0052 0.0046 0.0038
2 0.0055 0.0040 0.0035
3 0.0053 0.0034 0.0039
4 0.0049 0.0042 0.0032
答案1
你只需放两次东西;-)
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{pgfplots.groupplots}
\begin{document}
\pgfplotsset{
every non boxed x axis/.style={}
}
\fbox{
\begin{tikzpicture}[scale=1.0]
\begin{groupplot}[
scaled ticks=false,
group style={
group name=my fancy plots,
group size=1 by 2,
xticklabels at=edge bottom,
vertical sep=0pt
},
legend cell align=left,
legend pos=north west,
legend style = {font=\footnotesize},
width = 0.9\linewidth,height = 0.3\linewidth,
xtick=\empty,
yticklabel={\footnotesize ~\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\%}
]
\nextgroupplot[ymin=0.95,ymax=1.05,
ytick={1},
axis x line=top,
axis y discontinuity=parallel,
]
\addplot+[no marks,mark options={fill=black, color = black},color = black,mark size = 1pt] table {data1.dat};
\legend{~R,~TRC}
\nextgroupplot[ymin=-0.005, ymax=0.015,
ytick={0,0.01},
axis x line=bottom,
ylabel={\qquad\footnotesize Anzahl der Dissecting-Kanten},
xlabel={\footnotesize Testinstanzen},
height = 0.4\linewidth,
]
\addplot+[only marks,
color = blue,
mark = *,
mark options={fill=blue},
mark size = 1.5,
error bars/.cd,
error bar style={color=blue},
y dir = both,
y explicit,
x dir = none] table[x index={0},y index={1}, y error plus index ={2}, y error minus index ={3}]{data2.dat};
\end{groupplot}
\end{tikzpicture}
}
\end{document}