我如何将描绘解决方案集的数字线移动到|3x - 5| - x < 17
更接近的图形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}
答案1
像这样(我不确定你的问题是什么。据我所知,问题的主体与标题无关)?
编辑:
显然我没有很好地理解你的问题。现在我猜你的问题也是图表之间的距离。所以我添加了第二个图表并将其高度降低到。这样,第二个图表与上图底部1in
之间的距离就减小了。x-axis
对于这两个图,我还定义了共同点pgfplotsset
,从而使代码更短一些:
编辑2:
如果你不喜欢用线指针指向你的函数图,那么可以用pin
下面的选项代替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}
现在上述 MWE 的结果是:
更正后的答案能满足您的要求吗?