为了练习,我想用图形表示函数定义的域。该域由三个不等式描述。
这就是我目前所做的。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.5]
% Arc from (-sqrt(2)/2,-sqrt(2)/2) to (sqrt(2)/2,sqrt(2)/2)
\draw[dashed] (225:1) arc (225:45:1) ;
% Ligne y = x
\draw[domain=-2:-sqrt(2)/2,smooth,variable=\x,dashed] plot ({\x},{\x});
\draw[domain=sqrt(2)/2:2,smooth,variable=\x,dashed] plot ({\x},{\x});
% Ligne verticale x = 2
\draw[very thick] (2,2) -- (2,3);
% Axes
\draw[dotted,->] (-2,0) -- (3,0) node[right] {$x$};
\draw[dotted,->] (0,-2) -- (0,2) node[above] {$y$};
% Étiquettes
\node at (1,1) [yshift=1cm, above right] {$y=x$};
\node at (2,1) [right,yshift=2.5cm] {$x=2$};
\node at (1.2,0.5) [xshift = -3cm, above left] {$x^2+y^2=1$};
% Légende pour le domaine
\node at (3.5,1) [right,align=left] {Domaine de définition :\\(à l'extérieur du cercle, au-dessus de $y=x$,\\à gauche de $x=2$)};
\end{tikzpicture}
\end{document}
得到下图
如何填充该域并生成类似下图 (d) 的图形?
提前非常感谢您。
答案1
像这样:
代码:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage[margin=.5cm]{geometry}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\fill[cyan!40,opacity=.3] (-4,-4) rectangle (2,5);
\fill[white] (-4,-4)--(2,-4)--(2,2)--cycle;
\draw[blue,line width=2pt] (2,2)--(2,5);
\draw[blue,line width=2pt,dashed] plot[domain=-4:2] (\x,\x);
\fill[white] (0,0) circle(1);
\draw[blue,line width=2pt,dashed] (.707,.707) arc(45:225:1);
\draw[gray!30] (-4,-4) grid (4,5);
\draw[-latex] (-4.2,0)--(4.3,0) node[right] () {\footnotesize $x$};
\foreach \i in {-4,...,-1,1,2,...,4}
\draw (\i,-0)--(\i,-0.1) node[below] () {\footnotesize \i};
\draw[-latex] (0,-4.2)--(0,5.3) node[above] () {\footnotesize $y$};
\foreach \i in {-4,...,-1,1,2,...,5}
\draw (0,\i)--(-.1,\i) node[left] () {\footnotesize \i};
\draw (-.2,-.2) node () {\footnotesize $O$};
\end{tikzpicture}
\end{document}
编辑:为了避免出现“双”垂直线,请移动此行代码:
\draw[蓝色,线宽=2pt] (2,2)--(2,5);
作为环境中的最后一行tikzpicture
。