答案1
试试这个代码:
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (-3,0)--(3,0);
\foreach \x in {-2,-1,2}{
\draw (\x,-1.5)--(\x,.1);
\node[above] at (\x,0.1) () {\small \x};}
\node[left] at (-2.5,-.5) {$f_1$};
\draw[dashed] (-2.5,-.5)--(-1,-.5) ;
\draw[fill] (-1,-.5) circle(2pt) (-1,-.5)--(3,-.5);
\node[left] at (-2.5,-1) {$f_2$};
\draw (-2.5,-1)--(-2,-1);
\draw[fill] (-2,-1) circle(2pt);
\draw[dashed](-2,-1)--(2,-1) ;
\draw[fill] (2,-1) circle(2pt);
\draw (2,-1)--(3,-1);
\node[left] at (-2.5,-1.5) {$f_1\cdot f_2$};
\draw[dashed] (-2.5,-1.5)--(-2,-1.5);
\draw[fill] (-2,-1.5) circle(2pt);
\draw(-2,-1.5)--(-1,-1.5) ;
\draw[fill] (-1,-1.5) circle(2pt);
\draw[dashed] (-1,-1.5)--(2,-1.5);
\draw[fill] (2,-1.5) circle(2pt);
\draw (2,-1.5)--(3,-1.5);
\end{tikzpicture}
\end{document}
输出:
对于第二张图片,用以下代码替换 tikzpicture:
\begin{tikzpicture}
\draw[-latex] (-6,0)--(2,0);
\foreach \x in {-5,-4,1}{
\draw (\x,-2)--(\x,.1);
\node[above] at (\x,0.1) () {\small \x};}
\node at (-5,-.05) () {*};
\draw (-6,-1.5)--(2,-1.5);
\node at (-6,-.5) {N)\quad +};
\node at (-4.5,-.5) () {+};
\node at (-2,-.5) () {-};
\node at (1.5,-.5) () {+};
\node at (-6,-1) {D)\quad -};
\node at (-4.5,-1) () {+};
\node at (-2,-1) () {+};
\node at (1.5,-1) () {+};
\node at (-5.6,-2) {-};
\node at (-4.5,-2) () {+};
\node at (-2,-2) () {-};
\node at (1.5,-2) () {+};
\node at (-5,-1.55) () {*};
\end{tikzpicture}
你有: