
학생들이 과제에 상자 수염 플롯을 그릴 수 있도록 빈 상자를 만들려고 합니다.
\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}