addplot 명령을 사용하여 스크립트 스타일로 눈금 표시 라벨링 및 화살촉 배치

addplot 명령을 사용하여 스크립트 스타일로 눈금 표시 라벨링 및 화살촉 배치

제공된 코드는 TikZ에게 y = (x^{2} - 4)/(x + 2)에 대한 그래프를 그리도록 지시합니다. 몇 가지 수정이 필요합니다. 그래프는 y = x - 2 선과 같습니다. 이 함수 그래프의 양쪽 끝에 화살촉을 얻으려면 어떻게 해야 합니까?

오른쪽 화살촉의 약간 오른쪽 아래에 있는 x축에 $x$ 레이블을 붙이는 방법과 오른쪽 화살촉의 약간 오른쪽에 있는 y축에 $y$ 레이블을 붙이는 방법은 무엇입니까? 위쪽 화살촉? 흰색 상자 안과 그 안에 눈금 "-2" 조판을 가져오는 방법 scriptstyle- 점 (-2,0)과 (-2,-4) 사이에 점선을 그 위에 그리는 것을 원하지 않습니다. y축을 어떻게 줄이나요? 너무 낮게 그려졌습니다.

축에 대한 코드에는 xmax=8,ymax=7및 이라는 두 가지 명령이 있습니다 restrict y to domain=-7:10. 그들은 TikZ에게 무엇을 그리라고 지시하나요? 왜 거기 xmin에 명령이 없습니까 ymin?

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}


\begin{document}

\hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[axis equal image,
          xmax=8,ymax=7,
          axis lines=middle,
          restrict y to domain=-7:7,
          enlargelimits={abs=1cm},
          axis line style={latex-latex},
          ticklabel style={fill=white},
          ytick=\empty,
          xtick={-2}
          %xlabel=$x$,ylabel=$y$,
]
\addplot[domain=-10:10,mark=none,samples=10] {x - 2} node [above left, yshift=3pt]{$\scriptstyle{y}=\frac{x^{\scriptscriptstyle{2}} - 4}{x + 2}$};
\draw [thin,dashed] (-2,0) -- (-2,-4);
\draw [fill=white] (-2,-4) circle [radius=1.5pt] node[left]{$\scriptstyle{(-2, \, -4)}$};
\end{axis}
\end{tikzpicture}
\hspace{\fill}

\end{document}

답변1

지금쯤이면 이미 이해하셨겠지만, 다른 사람이 이것을 보고 궁금해할 경우를 대비해.

  • 화살촉: 기본적으로 축에 사용한 것과 동일한 방법으로 옵션 <->에 추가합니다 \addplot.
  • 축 레이블 위치: 다음을 사용하여 앵커를 변경합니다.

    xlabel style={anchor=north west},
    ylabel style={anchor=south west}
    
  • 눈금 라벨 글꼴 크기font=\scriptsize: 에 추가하세요 ticklabel style.
  • 라인 아래의 체크라벨: 간단한 방법은 옵션 axis on top에 추가하는 것입니다 axis.
  • xmin/ ymin: 왜 그 열쇠가 존재하지 않는다고 하시는지 모르겠습니다. 그들이하다. 그리고 설정은 yminy축을 줄이는 방법입니다.
  • restrict y to domain: 내 생각에 정확히 말한 대로 수행되며, 주어진 도메인 외부의 y 값을 필터링합니다.

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

\documentclass[10pt]{amsart}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
          axis on top, % added
          axis equal image,
          xmax=8,ymax=7,
          xmin=-3,ymin=-4,
          axis lines=middle,
          restrict y to domain=-7:7,
          enlargelimits={abs=1cm},
          axis line style={latex-latex},
          ticklabel style={fill=white,font=\scriptsize}, % added font
          ytick=\empty,
          xtick={-2},
          xlabel=$x$,ylabel=$y$,
          xlabel style={anchor=north west}, % added
          ylabel style={anchor=south west}, % added
]
\addplot[domain=-10:10,mark=none,samples=10,<->] {x - 2} node [above left, yshift=3pt]{$\scriptstyle{y}=\frac{x^{\scriptscriptstyle{2}} - 4}{x + 2}$};
\draw [thin,dashed] (-2,0) -- (-2,-4);
\draw [fill=white] (-2,-4) circle [radius=1.5pt] node[left]{$\scriptstyle{(-2, \, -4)}$};
\end{axis}
\end{tikzpicture}
\end{document}

관련 정보