我有一个使用此代码生成的带有一些误差线的图,但是误差线很混乱。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{
every axis/.append style={
scale only axis,
},
/tikz/every picture/.append style={
baseline,
trim axis left,
trim axis right,
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=4.5in,
height=3.5in,
scale only axis,
xmode=log,
xmin=0.001,
xmax=1,
xminorticks=true,
ymin=0,
ymax=250
]
\addplot [color=blue,solid,forget plot]
plot [error bars/.cd, y dir = both, y explicit]
table[row sep=crcr, y error plus index=2, y error minus index=3]{0.0625469 25.07 0.25 0.25\\
0.0390918 54.77 0.649999999999999 0.649999999999999\\
0.0244324 154.33 1.5 1.5\\
0.0152702 200 5.5 5.5\\
0.00954391 208.67 5.5 5.5\\
0.00596494 215.33 6 6\\
0.00372809 219 2.5 2.5\\
0.00233006 220.67 5 5\\
0.00145628 221 1.5 1.5\\
};
\end{axis}
\end{tikzpicture}%
\end{document}
但如果我删除
\pgfplotsset{
every axis/.append style={
scale only axis,
},
/tikz/every picture/.append style={
baseline,
trim axis left,
trim axis right,
}
}
看起来不错。问题就像pgfplotset
我文档开头的那个控制所有对齐和轴修剪的命令一样。有什么解决办法吗?
谢谢
答案1
将参数trim axis left
和trim axis right
从移动pgfplotsset
到tikzpicture
环境:
代码
\documentclass[border=1cm]{standalone}%{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{
every axis/.append style={
scale only axis,
},
/tikz/every picture/.append style={
baseline,
}
}
\begin{document}
\begin{tikzpicture}[trim axis left,
trim axis right]
\begin{axis}[%
width=4.5in,
height=3.5in,
scale only axis,
xmode=log,
xmin=0.001,
xmax=1,
xminorticks=true,
ymin=0,
ymax=250
]
\addplot [color=blue,solid,forget plot]
plot [error bars/.cd, y dir = both, y explicit]
table[row sep=crcr, y error index=2, y error index=3]{0.0625469 25.07 0.25 0.25\\
0.0390918 54.77 0.649999999999999 0.649999999999999\\
0.0244324 154.33 1.5 1.5\\
0.0152702 200 5.5 5.5\\
0.00954391 208.67 5.5 5.5\\
0.00596494 215.33 6 6\\
0.00372809 219 2.5 2.5\\
0.00233006 220.67 5 5\\
0.00145628 221 1.5 1.5\\
};
\end{axis}
\end{tikzpicture}%
\end{document}