我有以下箱线图:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[title = {Deletion of Focal and Arm-level SCNAs},ylabel = {$log_{2}(I_{C}/I_{N})$},
boxplot/draw direction=y,
xtick={1,2},
xticklabels={Focal, Arm}
]
\addplot+[mark options = {blue},
boxplot prepared={
lower whisker=-0.9197604,
lower quartile=-0.4621040,
median=-0.2362183,
upper quartile=-0.1566109,
upper whisker=-0.1003486
}, color = blue
] coordinates {};
\addplot+[mark = *,mark options = {blue},
boxplot prepared={
lower whisker=-0.2970707,
lower quartile=-0.2019435,
median=-0.1603655,
upper quartile=-0.1199740,
upper whisker=-0.1012605
}, color = blue
] coordinates {(0,-0.3299711)(0,-0.3299711)(0,-0.3642782)(0,-0.3930741)(0,-0.4372732)(0,-0.6161027)};
\draw[black, dashed]
(axis cs:0, -0.1) coordinate (tmp)
(current axis.west |- tmp) -- (current axis.east |- tmp);
\end{axis}
\end{tikzpicture}
\hspace{0.15cm}
\end{document}
得到:
我想修改 yaxis,以便它可以在标签中包含零。有什么简单的技巧吗?谢谢!
答案1
使用 pgfplots 文档进行简单检查http://texdoc.net/texmf-dist/doc/latex/pgfplots/pgfplots.pdf第 223 页,产生以下单行编辑:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[title = {Deletion of Focal and Arm-level SCNAs},ylabel = {$log_{2}(I_{C}/I_{N})$},
boxplot/draw direction=y,
xtick={1,2},
xticklabels={Focal, Arm},
ymin=-1, ymax=0 %%%%%%%%%%%%%%%%%%%%%%%%%%% One Line edit
]
\addplot+[mark options = {blue},
boxplot prepared={
lower whisker=-0.9197604,
lower quartile=-0.4621040,
median=-0.2362183,
upper quartile=-0.1566109,
upper whisker=-0.1003486
}, color = blue
] coordinates {};
\addplot+[mark = *,mark options = {blue},
boxplot prepared={
lower whisker=-0.2970707,
lower quartile=-0.2019435,
median=-0.1603655,
upper quartile=-0.1199740,
upper whisker=-0.1012605
}, color = blue
] coordinates {(0,-0.3299711)(0,-0.3299711)(0,-0.3642782)(0,-0.3930741)(0,-0.4372732)(0,-0.6161027)};
\draw[black, dashed]
(axis cs:0, -0.1) coordinate (tmp)
(current axis.west |- tmp) -- (current axis.east |- tmp);
\end{axis}
\end{tikzpicture}
\hspace{0.15cm}
\end{document}