tikz的函数绘图示例

来源:互联网 发布:sharpdesk桌面软件 编辑:程序博客网 时间:2024/06/05 16:50

tikz示例:主要是演示如何绘制函数图和求曲线的交点.


\documentclass{beamer}\input{tikzall.tex} %包含所有的tikz包\begin{document}\begin{frame}\begin{tikzpicture}[domain=-4:3.5,line width=2pt]\clip (-5,-5) rectangle (6,6);%只在这个区域内画图%绘制网格\draw[ thin,color=gray] (-4,-2) grid (4,4);%绘制y=sin(x)\draw[color=blue,name path=c1] plot (\x,{sin(\x r)})        node[right] {$f(x) = \sin x$};%绘制y= 0.1 * e^ x\draw[color=black,name path=c2] plot (\x,{0.1*exp(\x)})        node[right] {$f(x) = 0.1 * e^ x$}; %求交点, i-\s是每个交点的名称.i是前缀  \t表示总的交点数   \fill [name intersections ={of ={ c1 and c2},name=i,total=\t}]        \foreach \s in {1,...,\t}{(i-\s) circle(3pt) node[above]{\s}};\end{tikzpicture}\end{frame}\end{document} 

注意sin(\x r)的里面有个r表示,要将degree转换为弧度.domain=-4:3.5表示x的取值范围.

图形如下:

文件\input{tikzall.tex} %(包含所有的tikz包),是我的加载宏包文件博客里面有.

原创粉丝点击