
나는이 pgfplot을 가지고 있습니다
\begin{tikzpicture}[baseline]
\begin{axis}[
ymajorgrids,
legend style={at={(0.5,1.05)}, anchor=south,legend columns=3},
ybar,
bar width=0.5cm,
ylabel=Ratio vs. original,
xtick={1, 2, 3, 4},
ymin=0,
width=\textwidth,
height=7cm
]
\addplot+ [DarkRed] (1, 0.9166278045494584);
\addplot+ [BlueViolet] (2, 0.9745841753458725);
\addplot+ [CadetBlue] (3, 0.7903000155448467);
\addplot+ [Blue] (4,0.9375097155293016);
\end{axis}
\end{tikzpicture}
x축의 tikcs에서 막대의 오프셋을 어떻게 제거할 수 있습니까?
답변1
나는 당신이 다음을 찾고 있다고 생각합니다 :
아래 MWE에서 코드 조각과 비교하여 변경된 사항은 다음과 같이 표시됩니다 % <---
.
\documentclass[a4paper,12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz,xcolor}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{axis}[
ymajorgrids=true,
%legend style={at={(0.5,1.05)}, anchor=south,legend columns=3}, % it is not used
ybar=2mm, % <----
bar width=8mm, % <----
bar shift=0mm, % <---- remove offset
ylabel={Ratio vs. original},
enlarge x limits=0.2,
width=0.5\textwidth, % <----
height=7cm
]
\addplot + [red] coordinates {(1, 0.9166278045494584)};
\addplot + [green] coordinates {(2, 0.9745841753458725)};
\addplot+ [magenta] coordinates {(3, 0.7903000155448467)};
\addplot+ [yellow] coordinates {(4,0.9375097155293016)};
\end{axis}
\end{tikzpicture}
\end{document}