Pgfplots: 플롯이 축을 초과하도록 만드는 방법

Pgfplots: 플롯이 축을 초과하도록 만드는 방법

pgfplots를 사용하여 스파이크를 계획하고 있습니다. (4)까지만 y축을 만들고 싶습니다. 그러나 나는 스파이크 자체의 플롯이 y축을 넘어(예: 10까지) 계속되기를 원합니다.

이를 수행할 수 있는 방법이 있습니까? 이것은 지금까지 내 코드입니다.

\documentclass{article}
\usepackage{pgfplots}

\pgfkeys{/pgfplots/Axis Style/.style={
width=4.5cm, height=5.8cm,
axis x line=center, 
axis y line=middle, 
samples=300,
ymin=-1, ymax=6,
xmin=-1, xmax=4,
domain=-1:4,
 }}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[font=\scriptsize,every axis legend/.append style={ legend pos=north east,font=\scriptsize},
  Axis Style,
  ytick={-1,1,2,3},yticklabels={$-1$,$1$,$2$,$3$},
  xtick={-1,1,2,3},xticklabels={$-1$,$1$,$2$,$3$},
  xlabel={$x$}, ylabel={$y=\frac{x(x-3.01)}{x-3}$},
  xticklabel shift=9pt,
  legend style={draw=none},
  tick style={color=black},
  x label style={anchor=west},
  y label style={anchor=south west} ]
  \addplot plot[mark=none,  thick, black] (\x,{(\x)/(\x-3)*(\x-3.01)});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

답변1

옵션은 clip=false원하는 대로 수행됩니다.

실제 플롯에 대한 추가 개선 및 제어를 통해 , 및 restrict y to domainunbounded coords를 제공할 수 있습니다 .samplessamples at

암호

\documentclass[tikz,convert=false]{standalone}
\usepackage{pgfplots}

\pgfplotsset{Axis Style/.style={
  width=4.5cm, height=5.8cm,
  axis x line=center, 
  axis y line=middle, 
  samples=300,
  ymin=-1, ymax=6,
  xmin=-1, xmax=4,
  domain=-1:4,
}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[font=\scriptsize,every axis legend/.append style={ legend pos=north east,font=\scriptsize},
  Axis Style,
  ytick={-1,1,2,3},yticklabels={$-1$,$1$,$2$,$3$},
  xtick={-1,1,2,3},xticklabels={$-1$,$1$,$2$,$3$},
  xlabel={$x$}, ylabel={$y=\frac{x(x-3.01)}{x-3}$},
  xticklabel shift=9pt,
  legend style={draw=none},
  tick style={color=black},
  x label style={anchor=west},
  y label style={anchor=south west},
  clip=false,
  restrict y to domain=-1:17,
  unbounded coords=jump
   ]
  \addplot plot[mark=none, samples=1000, thick, black] (\x,{(\x)/(\x-3)*(\x-3.01)});
\end{axis}
\end{tikzpicture}
\end{document}

산출

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

관련 정보