3

In the code below if I use the following code soft clip={domain=-3:3}, I get the graph on the top. If I use soft clip={domain=-2.99:3}, I get the graph on the bottom. Why does -3 not work?

\documentclass[11pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows,patterns,decorations,intersections,matrix,calc,backgrounds,positioning}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
    axis x line=center, axis y line=center,
    ticks=none,
    xlabel={$x$}, ylabel={$y$},
    xlabel style={below right}, ylabel style={above left},
    xmin=-3.25, xmax=3.25, ymin=-1.25, ymax=1.25,
    x=1.5cm/1, y=2cm/1,
    unit vector ratio*=1 1 1
    ]
    \addplot[domain=-3:3, samples=200, smooth,name path=C] {(x^2-1)/(x^2+1)};
    \addplot[name path=HA, domain=-3:3, dashed] {1};
    \draw (axis cs:1, 0.9) node[above] {\small$y=1$};
    \draw (axis cs:0.5, 0.25) node {\textbf{\small$R_1$}};
    \addplot[pattern=north west lines, pattern color=brown!50]fill between[of=C and HA, soft clip={domain=-2.99:3}];
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

enter image description here enter image description here

  • If you remove scale option or decrease it to 0.8, then your MWE works also width soft clip={domain=-3:3} – Zarko Mar 20 '16 at 22:00
  • 1
    Any news? Should we close your question as "unclear what you're asking"? – Zarko Apr 27 '17 at 21:10
1

Let me extend my comment to answer- You have two possibilities:

  • reduce scale: scale=0.8
  • remove scale and for determining image width use option width=<length>

And of course combination of both aforementioned possibilities. In all cases the result is very similar (difference is in image size, which can be simple determined in the second case):

enter image description here

\documentclass[11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14} % <-- added

\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows,backgrounds,calc,decorations,intersections,matrix,patterns,positioning}

\begin{document}
\begin{center}
\begin{tikzpicture}%[scale=0.8]
\begin{axis}[
    width=7cm,  % <-- here determine image size
    axis x line=center, axis y line=center,
    ticks=none,
    xlabel={$x$}, ylabel={$y$},
    xlabel style={below right}, ylabel style={above left},
    xmin=-3.25, xmax=3.25, ymin=-1.25, ymax=1.25,
    x=1.5cm/1, y=2cm/1,
    unit vector ratio*=1 1 1
    ]
    \addplot[domain=-3:3, samples=200, smooth,name path=C] {(x^2-1)/(x^2+1)};
    \addplot[name path=HA, domain=-3:3, dashed] {1};
    \draw (axis cs:1, 0.9) node[above] {\small$y=1$};
    \draw (axis cs:0.5, 0.25) node {\textbf{\small$R_1$}};
    \addplot[pattern=north west lines, pattern color=brown!50]
        fill between[of=C and HA, soft clip={domain=-3:3}]; %<-- see soft clip
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.