LaTeX:TikZ练习1

练习结果图

在这里插入图片描述

具体代码

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usepackage{siunitx} %需要用到\ang[options]{degrees}命令
\newcommand{\iangle}{120}
\usepackage{ctex}
\usepackage[landscape]{geometry} %使得页面横置


\begin{document}
\begin{figure}[htbp]
	\centering
	\begin{tikzpicture}[scale=2.8] %scale参数可以使得图形放大一定的倍数而本身的字体大小可以保持不变。
		%画左边的圆
		%scope环境里够成一整个区块,然后可以使这一整个区块进行平移。
		\begin{scope}[xshift=-1.75cm] 
			\fill[fill=gray,fill opacity=0.2]
			(0,0) -- (0:1) arc (0:\iangle:1) -- cycle;
			\filldraw[fill=gray,fill opacity=0.5]
			(0,0) --(0:0.3) arc (0:\iangle:0.3) -- cycle;
			\draw[->] (-1.2,0) -- (1.2,0);
			\draw[->] (0,-1.2) -- (0,1.2);
			\draw[thick] (0,0) circle (1);
			\coordinate[label=\iangle:$P$] (P) at (\iangle:1);
			\coordinate[label=below:$P_0$] (P0) at (P |- 0,0);
			\draw (0,0) -- (P);
			\draw (P) -- (P0);
			\node[right] at (\iangle/2:0.3) {\ang{\iangle}};
		\end{scope}
		%画右边的正弦曲线
		\draw[->] (0,0) -- ({rad(210)},0);
		\draw[->] (0,-1.2) -- (0,1.2);
		\draw[thick,domain=0:rad(210)] plot(\x,{sin(\x r)}) node[right] {$\sin x$};
		\foreach \t in {0,90,180} {
			\draw ({rad(\t)},-0.05) -- ({rad(\t)},0.05);
			\node[below,outer sep=2pt,fill=white,font=\small]
			at ({rad(\t)},0) {\ang{\t}};	
		}
		\foreach \y in {-1,1} {
			\draw (-0.05,\y) -- (0.05,\y);
		}
		\coordinate[label=above:$Q$] (Q) at ({rad(\iangle)},{sin(\iangle)});
		\coordinate[label=below:$Q_0$] (Q0) at (Q |- 0,0);
		\draw (Q) -- (Q0);
		%左右相互连接
		\draw[dashed] (P) -- (Q);
	\end{tikzpicture}
	\caption{正弦函数与单位圆(TikZ实现)}
\end{figure}
\end{document}

备注:代码借鉴至刘海洋的《LaTeX入门》

新浪微博

可关注我的新浪微博,里边动不动会发一些Stata,Latex,Matlab的tips。当然,本人时不时会背一些英语单词,请不要感到烦躁。

猜你喜欢

转载自blog.csdn.net/wangmeitingaa/article/details/88849646