1

I have this code. It will create a nice graph if I didn't have "clip=false", but once I add it, the whole graph is completely distorted. Why is it happening? I want to put a text "A text" outside the axis.

\documentclass{article}
\usepackage[margin=0.25in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
\begin{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    x label style={at={(axis description cs:1,0)},anchor=north},
    y label style={at={(axis description cs:-0.05,1.05)},rotate=270,anchor=north},
    ymin=0, ymax=3,
    xmin=0, xmax=3,
    ticks=none,
    clip=false
]
%Below the red parabola is defined
\addplot [
    domain=0:3,
    samples=100, 
    y domain=0:3,
]
{1/x};
\node[] at (axis cs: -0.14,1.2) {$A text$};

\end{axis}
\end{tikzpicture}

\end{document}
1
  • use clip mode=individual instead of clip=false ... Oct 15, 2021 at 10:50

1 Answer 1

2

PGFPlots compat=1.9 is really old. Your plot near y-axis is large, so you need to restrict y to domain. y domain for your plot does not make sense as it is not a 2D plot in 3D. $A text$ is math! It means A*t*e*x*t - that is why there is no space between "A" and "text". Do not use axis cs: - it is default for new versions of PGFPlots.

\documentclass[border=1 cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    xmin=0, xmax=3,
    ymin=0, ymax=3,
    ticks=none,
    clip=false,
    restrict y to domain=0:3,
]
\addplot[
    red,
    domain=0:3,
    samples=100, 
]
{1/x};
\node[] at (-0.14,1.2) {$A text$};
\end{axis}
\end{tikzpicture}
\end{document}

A parabola graph

Not the answer you're looking for? Browse other questions tagged .