Pgfplots: Como fazer o gráfico ultrapassar os eixos

Pgfplots: Como fazer o gráfico ultrapassar os eixos

Estou traçando um pico usando pgfplots. Quero fazer o eixo y apenas até (4). No entanto, quero que o gráfico do pico continue além do eixo y (digamos, até 10).

Existe uma maneira possível de fazer isso? Este é o meu código até agora:

\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}

Responder1

A opção clip=falsefaz o que você deseja.

Melhorias adicionais e controle sobre o enredo real podem fornecer as chaves restrict y to domain, unbounded coordse .samplessamples at

Código

\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}

Saída

insira a descrição da imagem aqui

informação relacionada