
다음은 제가 복사하려는 막대 그래프입니다(숫자가 아니라 그래프임).
그리고 여기 내 시도가 있습니다.
그리고 여기에 코드가 있습니다.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
x tick label style={/pgf/number format/1000 sep=},
ylabel=$\Omega_{total}$,
xlabel=$q_A$,
ybar interval=0.7]
\addplot
coordinates {(0,330) (1,210) (2,126) (3,70) (4,35) (5,15) (6,5) (7,1)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
7번째 막대가 표시되지 않고 x축이 원래 위치보다 낮은 것을 볼 수 있습니다. 참조 그래프처럼 보이도록 어떻게 변경할 수 있나요? 색깔도 그렇고. 미리 감사드립니다.
답변1
원하는 대로 축 옵션을 조정할 수 있습니다. 출발점은 다음과 같습니다.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
x tick label style={/pgf/number format/1000 sep=},
xlabel=$q_A$,
axis x line*=bottom,
ylabel=$\Omega_{total}$,
ybar interval=0.7,
ymin=0,
ymax=400,
ytick align=outside,
axis y line*=left,
]
\addplot[fill=gray!40]
coordinates {(0,330) (1,210) (2,126) (3,70) (4,35) (5,15) (6,5) (7,1)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}