축을 방해하지 않도록 pgfplot에서 y축 레이블을 어떻게 이동할 수 있습니까?

축을 방해하지 않도록 pgfplot에서 y축 레이블을 어떻게 이동할 수 있습니까?

pgfplots를 사용하여 다음 그래프를 그리려고 합니다.

\begin{equation*}
\begin{tikzpicture}
    \begin{axis}[
    axis lines=middle,
    axis line style={latex-latex},
    xmin=-5,ymin=-1,xmax=5,ymax=2,
    samples=100,
    grid=major,
    xlabel={\(x\)},
    ylabel={\(ReLU(x) = max(0,x)\)},
    title={Rectified Linear Unit Function}]
\addplot[black, thick]{max(0,x)};
\end{axis}
\end{tikzpicture}
\end{equation*}

다음과 같습니다.

여기에 이미지 설명을 입력하세요

그래프를 가리지 않도록 y축 레이블을 축의 왼쪽으로 이동할 수 있는 방법이 있나요? 나는 그것을 축 끝에 놓을 수 있다는 것을 알고 있지만 제목을 가리게 됩니다.

답변1

환영! 키를 ylabel사용하여 모양을 제어할 수 있습니다 ylabel style.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\re}{Re}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{equation*}
\begin{tikzpicture}
    \begin{axis}[
    axis lines=middle,
    axis line style={latex-latex},
    xmin=-5,ymin=-1,xmax=5,ymax=2,
    samples=100,
    grid=major,
    xlabel={\(x\)},
    ylabel={\(\re LU(x) = \max(0,x)\)},
    ylabel style={yshift=-0.5ex,anchor=north east},
    title={Rectified Linear Unit Function}]
\addplot[black, thick,samples at={-5,0,5}]{max(0,x)};
\end{axis}
\end{tikzpicture}
\end{equation*}
\end{document}

여기에 이미지 설명을 입력하세요

플롯을 환경에 배치하는 것이 좋은 아이디어인지는 모르겠지만 equation*일단 유지했지만 해당 수학 연산자에 \max및 를 사용하는 것이 좋은 아이디어라고 생각합니다. \re나는 또한 더 많은 정의를 samples at={-5,0,5}수행하는 데 사용합니다.max

하지만 에서 눈금 레이블을 제거할 수도 있습니다 y=2.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\re}{Re}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
    axis lines=middle,
    axis line style={latex-latex},
    xmin=-5,ymin=-1,xmax=5,ymax=2,
    ytick={1},
    samples=100,
    grid=major,
    xlabel={\(x\)},
    ylabel={\(\re LU(x) = \max(0,x)\)},
    ylabel style={yshift=-0.5ex,anchor=east},
    title={Rectified Linear Unit Function}]
\addplot[black, thick,samples at={-5,0,5}]{max(0,x)};
\end{axis}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보