Alinhando um pgfplot acima de outro pgfplot

Alinhando um pgfplot acima de outro pgfplot

Como movo a reta numérica que representa o conjunto de soluções para |3x - 5| - x < 17mais perto do gráfico de y = |3x - 5| - x?

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}



\usepackage{pgfplots}
\pgfplotsset{compat=1.11}



\begin{document}

\begin{tikzpicture}

\begin{axis}[name=plot1, width=2.75in, height=2.75in, axis x line=middle, axis y line=none, clip=false,
    domain=-5:15,
    xtick={-3, 11},ytick={\empty},
    ticklabel style={font=\scriptsize},
    xticklabels={-3, 11},
    axis line style={latex-latex},
    axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
]

\addplot[draw=none] {0};

\draw[line width=1.2pt] (-3, 0) -- (11, 0);
\draw[draw=black, fill=white] (-3, 0) circle [radius=1.5pt];
\draw[draw=black, fill=white] (11, 0) circle [radius=1.5pt];

\end{axis}

\begin{axis}[at=(plot1.north), anchor=south, width=2.75in, height=2.75in, axis lines=middle, clip=false,
    axis lines=middle, clip=false,
    xmin=-8,xmax=18,
    ymin=-3,ymax=25,
    restrict y to domain=-3:25,
    xtick={-3,11}, ytick={\empty},
    ticklabel style={font=\scriptsize},
    xticklabels={\makebox[0pt][r]{$-$}3, 11},
    axis line style={latex-latex},
    xlabel=\textit{x},ylabel=\textit{y},
    axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
    xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
    ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]

\addplot[samples=2, blue, domain=-5:5/3] {-4*x + 5};
\addplot[samples=2, blue, domain=5/3:15] {2*x - 5};
\addplot[samples=2, latex-latex, domain=-8:18] {17};

%The equation for the piece of the function over the interval (-5, -15) is y = |3x - 5| - x.
\coordinate (A) at (14.5,24);
\coordinate (B) at (5/3,-5/3);
\coordinate (C) at (-8,17);

\end{axis}


%A "pin" is drawn between the label for the graph of y = |3x - 5| - x and a point on the graph.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.75cm!90:(B)$);
\node[blue, anchor=west, inner sep=0, font=\footnotesize] at ($(A)!0.75cm!90:(B)$) {\makebox[0pt][l]{$y = \vert3x - 5\vert - x$}};

%The label for the horizontal line is typeset.
\node[anchor=east, inner sep=0, font=\footnotesize] at ($(C) +(-0.15,0)$){$y = 17$};


\end{tikzpicture}


\end{document}

Responder1

Assim (não tenho certeza qual é o seu problema. O corpo da pergunta não está relacionado ao do título, pelo que entendi)?

editar: Aparentemente não entendi bem sua pergunta. Agora acho que o seu problema também é a distância entre os diagramas. Então eu adiciono o segundo diagrama e reduzo sua altura para 1in. Com isso a distância entre o x-axissegundo diagrama e a parte inferior do diagrama superior é reduzida.

Para ambos os diagramas eu também defino comum pgfplotssete com isso torno o código um pouco mais curto:

editar 2: se você não gosta de ter um ponteiro de linha para o gráfico de sua função, substitua a opção pinpor label:

\documentclass{amsart}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc,intersections}

\begin{document}
    \begin{tikzpicture}[dot/.style = {circle, fill,inner sep=2pt}]
\pgfplotsset{
    width=2.75in,
    clip=false,
    xmin=-11,xmax=22,
    restrict y to domain=-3:25,
    xtick={-3,11},
    xticklabels={\makebox[0pt][r]{$-$}3, 11},
    ticklabel style={font=\scriptsize},
    xlabel=\textit{x},ylabel=\textit{y},
    xlabel style={at={(ticklabel* cs:1)}, above right},
    ylabel style={at={(ticklabel* cs:1)}, above right}
            }
\begin{axis}[name=plot1,
    height=2.75in,
    axis lines=middle,
    ymin=-3,ymax=25,
    ytick={\empty},
            ]
\addplot[samples=2, blue, domain=-5:5/3] {-4*x + 5};
\addplot[samples=2, blue, domain=5/3:15] {2*x - 5}
    coordinate[pos=0.9, label={[font=\footnotesize]0:$|3x - 5| - x < 17$}] (aux);  % <---
\addplot[samples=2, latex-latex, domain=-8:18] {17}
    node[font=\footnotesize,above left] {$y=17$};   % <---
\end{axis}
%
\begin{axis}[at=(plot1.south), anchor=north,
    height=1in, % minimal height which pgfplots accept is about 0.7 in
    axis x line=middle,
    axis y line=none,
]
\addplot[line width=1.2pt, mark=*] coordinates {(-3,0) (11,0)};
\end{axis}
    \end{tikzpicture}
\end{document}

Agora o resultado do MWE acima é:

insira a descrição da imagem aqui

A resposta corrigida dá o que você procura?

informação relacionada