答案1
编辑(1):在编辑问题并在评论中讨论后,问题现在更加清晰了。您还提供了第一张图片的解决方案(谢谢!),因此下面是完整的 MWE(最小工作示例),其中包含所有图片及其绘制方式的描述。如果您只需要图片,您可以简单地从 MWE 中提取它们。
编辑(2):MWE 中添加了关于如何绘制图像的简短说明。还定义了用于缩短图像代码的新命令。
由于您是新手,让我为您提供一些解决问题的起点:
- 如果您使用 LaTeX,那么强烈建议您在编写数学时使用它的语法。TeX
$$
切换到数学环境(或从数学环境切换到文本)。在 LaTeX 中,为此目的定义\[
...\]
或\begin{equation*}
...\end{equation*}
。 - 对于绘制图表来说,
pgfplots
使用包似乎比使用纯包更好tikz
(老实说,这取决于你对它们的熟悉程度)。 - 除上述之外,还有其他套餐可供选择
pstricks
。
我猜你喜欢以以下形式写作业任务-解决方案:
\documentclass{article}
\usepackage[vmargin=20mm]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17,
%%%% common settings
axis lines=middle,
axis line style= {-Straight Barb},
axis on top,
x=7mm, y=3.5mm, % <---
%
xlabel=$x$,
xlabel style=right,
xmin=-4.5, xmax=4.5,
xtick={-4,-3,...,\Xmax}, % <---
%
ylabel=$y$,
ylabel style=above,
ymin=-8.5, ymax=4.5,
ytick={-8,-7,...,8},
%
tick style=black,
tick label style = {inner sep=1pt, font=\tiny},
%
no marks,
every axis plot post/.append style={draw=teal, very thick}
}
% abbreviations for use of axis minimal and maximal values
\newcommand\Xmin{\pgfkeysvalueof{/pgfplots/xmin}}
\newcommand\Xmax{\pgfkeysvalueof{/pgfplots/xmax}}
\newcommand\Ymin{\pgfkeysvalueof{/pgfplots/ymin}}
\newcommand\Ymax{\pgfkeysvalueof{/pgfplots/ymax}}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows.meta}
\begin{document}
For all images followed are determined global settings with \verb+\pgfplotsset+ in document preamble. Where is needed, they are overwritten by local defined options, for example with changed minimal and maximal axis size, size of axis units etc. This changes are described where are done.
Each images has three parts:
\begin{enumerate}
\item With \verb+\addplot [name patrh=A]+ is drawn border line of the inequality area. Their position is determined by two (or three) coordinates, which are calculated from given inequalities.
\item With \verb+\path [name path=B]+ is drawn invisible auxiliary line at bottom or right site of images, which is needed at coloring area of validity of inequality
\item Width \verb+\addplot [teal!30] fill between [of=A and B]+ is colored area of validity of given inequality.
\end{enumerate}
Tasks are:
\begin{enumerate}
\item Sketch the inequality shown below on the coordinate axes:
\[
y \leq -3:
\]
\[
\begin{tikzpicture}
\begin{axis}
\addplot [name path=A] coordinates { (\Xmin,-3) (\Xmax,-3) };
\path [name path=B] (\Xmin,\Ymin) -- (\Xmax,\Ymin)
node[above left, font=\footnotesize, text=black] {$y \leq 3$};
\addplot [teal!30] fill between [of=A and B];
\end{axis}
\end{tikzpicture}
\]
\item Sketch the inequality shown below on the coordinate axes:
\[
y > 3x - 3
\]
\[
\begin{tikzpicture}
\begin{axis}
\addplot [name path=A] coordinates { (\Xmin,-15) (\Xmax,9) };
\path [name path=B] (\Xmax,\Ymin)
node[above left, font=\footnotesize, text=black] {$y\leq 3x-3$}
-- (\Xmax,\Ymax);
\addplot [teal!30] fill between [of=A and B];
\end{axis}
\end{tikzpicture}
\]
\item Sketch the inequality shown below on the coordinate axes:
\[
x \geq 2y + 2
\]
\[
\begin{tikzpicture}
\begin{axis}
\addplot [name path=A] coordinates { (-15,\Ymin) (19,\Ymax) };
\path [name path=B] (\Xmin,\Ymin) -- (\Xmax,\Ymin)
node[above left, font=\footnotesize, text=black] {$x \geq 2y + 2$};
\addplot [teal!30] fill between [of=A and B];
\end{axis}
\end{tikzpicture}
\]
\item Sketch the region on a coordinate plane:
\[
x^2 + y^2 > 16
\]
Above inequality is fulfilled in outside of circle $x^2+y^2=r^2=16$. Drawing this parametric function with \verb+pgfplots+ is done in two steps: with arcus above $x$-axis and arcus below it. Coloring of the inequality region require to use two layers: background layer (\verb+main+) for drawing circle and layer above it (\verb+pre-main+) for coloring (see image code for this item).
For see circle as circle, it is necessary to use the same units on both axis, if \verb+x=7mm+ (set in \verb+\pgfplotsset+) then we need now set \verb+y=7mm+. By this image become (to much) taller, so at the same time it is sensible to reduce minimal and maximal value for $y$-axis:
%---------------------------------------------------------------%
% used is layered drawing %
%---------------------------------------------------------------%
\[
\pgfdeclarelayer{pre main}
\begin{tikzpicture}
\pgfsetlayers{pre main,main}
\begin{axis}[y=7mm, % <--
ymin=-4.5, % <--
samples=101]
\addplot [name path=A, domain=-4:4] {+sqrt(16-x^2)};
\addplot [name path=B, domain=-4:4] {-sqrt(16-x^2)};
\pgfonlayer{pre main}
% coloring of plane
\fill[teal!30] (\Xmin,\Ymax) -| (\Xmax,\Ymin)
node[above left, text=black] {$x^2 + y^2 > 16$}
-| cycle;
% coloring of circle
\addplot [white] fill between [of=A and B];
\endpgfonlayer
\end{axis}
\end{tikzpicture}
\]
\item Sketch the region on a coordinate plane:
\[
y > |x-2|
\]
That symmetry of this inequality, which is at $x=2$, can be easy to observe. the \verb+\xmin+ and \verb+xmax+ is increased for 2:
\[
\begin{tikzpicture}
\begin{axis}[xmin=-2.5, xmax=6.5,
ymin=-4.5] % reduce height of image
\addplot [name path=A] coordinates { (\Xmin,4.5) (2,0) (\Xmax,4.5) };
\path [name path=B] (\Xmin,\Ymin) -- (\Xmax,\Ymin)
node[above left, font=\footnotesize, text=black] {$y=|x-2|$};
\addplot [teal!30] fill between [of=A and B];
\end{axis}
\end{tikzpicture}
\]
\end{enumerate}
\end{document}