我正在尝试为我的学生创建一个空框,让他们在作业中绘制自己的箱线图:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\centerline{
\resizebox{15cm}{5cm}{
\begin{tikzpicture}
\begin{axis}
[ytick={\empty},yticklabels={,,},
ytick style={draw=none}, xmin = -1, xmax = 70,
xtick = {-10, 0, 10, 20, 30, 40,50,60, 70},
xticklabels={-10, 0, 10, 20, 30, 40,50,60,70}]
\end{axis}
\end{tikzpicture} }
}
\end{document}
这里的问题是我希望刻度为 0、10、20、30、40、50、60。但是,当我在单独的图像中绘制实际的箱线图时,我得到了正确的边界:
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{statistics}
\begin{document}
\centerline{
\resizebox{15cm}{5cm}{
\begin{tikzpicture}
\begin{axis}
[
ytick={0},
xtick = {0, 10, 20, 30, 40 ,50 ,60}
]
\addplot+[
boxplot prepared={
median=38,
upper quartile=46,
lower quartile=18,
upper whisker=59,
lower whisker=1
},
] coordinates {};
\end{axis}
\end{tikzpicture} }
}
\end{document}
我如何修改空白图像以便刻度线范围从 0 到 60?
答案1
例如:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
ytick=\empty,
ymin=0,ymax=1, % <-- added
xmin = -1,
xmax = 61, % modified
xtick = {0, 10, ..., 60}, % modified
width=\textwidth, % <-- added
height=0.3\textwidth % <-- added
]
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}