
저는 TeX의 초보자입니다. 그리고 이 히스토그램의 복사본을 만들려면 Tikz를 사용해야 합니다.
물론 나도 비슷한 걸 만들 수는 있다. 안타깝게도 복제본(90%)이 필요합니다. 누구든지 나를 도와줄 수 있나요?
내가 가진 것:
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={excellent, good, average, bad, awful},
ylabel = {probability},
xlabel = {Quality},
xtick=data]
\addplot[ybar,fill=white] coordinates {
(excellent,5)
(good,10)
(average,50)
(bad, 20)
(awful,15)
};
\end{axis}
\end{tikzpicture}
답변1
아마도 이와 같은 것일 것입니다.
\documentclass[11pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\pgfplotsset{
compat=newest,
xlabel near ticks,
ylabel near ticks
}
\begin{document}
\begin{tikzpicture}[font=\small]
\begin{axis}[
ybar,
bar width=20pt,
xlabel={Quality},
ylabel={Probability},
ymin=0,
ytick=\empty,
xtick=data,
axis x line=bottom,
axis y line=left,
enlarge x limits=0.2,
symbolic x coords={excellent,good,average,bad,awful},
xticklabel style={anchor=base,yshift=-\baselineskip},
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%}
]
\addplot[fill=white] coordinates {
(excellent,5)
(good,10)
(average,50)
(bad,20)
(awful,15)
};
\end{axis}
\end{tikzpicture}
\end{document}
답변2
다음은 작은 세부 사항을 수정하는 설정 모음입니다. 주석을 달면 그들이 무엇을 하고 있는지 확인할 수 있습니다. 화살촉의 출처는 DIN은 TikZ의 화살촉과 부화를 준수합니까?
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\makeatletter
% https://tex.stackexchange.com/questions/52786/din-conform-arrowheads-and-hatching-in-tikz
\pgfarrowsdeclare{DIN}{DIN}
{
\pgfutil@tempdima=0.5pt%
\advance\pgfutil@tempdima by.25\pgflinewidth%
\pgfutil@tempdimb=7.29\pgfutil@tempdima\advance\pgfutil@tempdimb by.5\pgflinewidth%
\pgfarrowsleftextend{+-\pgfutil@tempdimb}
\pgfutil@tempdimb=.5\pgfutil@tempdima\advance\pgfutil@tempdimb by1.6\pgflinewidth%
\pgfarrowsrightextend{+\pgfutil@tempdimb}
}
{
\pgfutil@tempdima=0.5pt%
\advance\pgfutil@tempdima by.25\pgflinewidth%
\pgfsetdash{}{+0pt}
\pgfsetmiterjoin
\pgfpathmoveto{\pgfpointadd{\pgfqpoint{0.5\pgfutil@tempdima}{0pt}}{\pgfqpoint{-4mm}{0.5mm}}}
\pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{0\pgfutil@tempdima}}
\pgfpathlineto{\pgfpointadd{\pgfqpoint{0.5\pgfutil@tempdima}{0pt}}{\pgfqpoint{-4mm}{-0.5mm}}}
\pgfpathclose
\pgfusepathqfillstroke
}
\pgfarrowsdeclarereversed{DIN reversed}{DIN reversed}{DIN}{DIN}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={excellent, good, average, bad, awful},
ylabel = {probability},
xlabel = {Quality},
ytick=\empty,ymin=0,
axis x line=bottom,
axis y line=left,
enlarge x limits=0.2,
axis line style={-DIN,ultra thin},
xtick=data,
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%},
ylabel near ticks,
xticklabel style={anchor=base,yshift=-3mm},
xtick style={draw=none},
every axis x label/.style={at={(current axis.south east)},anchor=north west}
]
\addplot[ybar,fill=white] coordinates {
(excellent,5)
(good,10)
(average,50)
(bad, 20)
(awful,15)
};
\end{axis}
\end{tikzpicture}
\end{document}