pgfplots画二维图真的很方便,多例比较
2016-06-15 20:58
281 查看
%直接PDFLATEX编译即可
\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide,pgfplots}
\begin{document}
\begin{tikzpicture}[domain=0:4]
\tkzInit[xmax=4.2,ymax=4.2,xmin=-1.2,ymin=-3.2,xstep=1]
\tkzGrid
\tkzAxeXY
\draw[color=red] plot (\x,\x) node[right] {$f(x)=x$};
\draw[color=orange,domain=-0.5:4] plot (\x,{0.05*exp(\x)}) node[right] {$f(x)=\frac{1}{20}\mathrm e^x$};
\draw[color=blue,domain=0:4] plot (\x,{sin(\x r)}) node[right] {$f(x)=\sin x$};
\draw[color=blue!50,x=1cm,y=0.5cm,domain=-0.5:2.4] plot (\x, {(\x)^3-4*(\x)+2}) node[right] {$f(x)=x^3-4x+2$};
\end{tikzpicture}
\end{document}
%直接PDFLATEX编译即可
\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[x=.5cm,xmin=0,ymin=0]
\addplot[mark=none,smooth,red,thick] expression[domain=0:12]{exp(((x-6)^2)/(-9))};
\addplot[mark=none,smooth,blue,thick] expression[domain=1:19]{exp(((x-10)^2)/(-25))};
\addplot[mark=none,smooth,ultra thick] expression[domain=7.5:12]{exp(((x-6)^2)/(-9))};
\addplot[mark=none,smooth,ultra thick] expression[domain=1:7.5]{exp(((x-10)^2)/(-25))};
\addplot[dotted,mark=none]coordinates{(6,0)(6,1)};
\addplot[dotted,mark=none]coordinates{(10,0)(10,1)(0,1)};
\addplot[dashed,mark=none]coordinates{(7.5,0)(7.5,0.7788)(0,0.7788)};
\node[pin=-45:{$P$}] at (axis cs:0,0.7788) {};
\node[pin=135:{$P_x$}] at (axis cs:7.5,0) {};
\end{axis}
\end{tikzpicture}
\end{document}
%直接PDFLATEX编译即可
\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide,pgfplots}
\begin{document}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->,>=angle 90] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->,>=angle 90] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
%plot选项请看pgfmanual手册第224页
\draw[color=red] plot (\x,\x) node[right] {$f(x)=x$};
\draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x)=\frac{1}{20}\mathrm e^x$};
%下面的sin函数,要注意弧度和度数单位的转换,手册第225页
\draw[color=blue] plot (\x,{sin(\x r)}) node[right] {$f(x)=\sin x$};
\draw[color=blue,x=1cm,y=0.5cm,domain=-0.5:2.4] plot (\x, {(\x)^3-4*(\x)+2}) node[right] {$f(x)=x^3-4x+2$};
\end{tikzpicture}
\end{document}
from: http://blog.sina.com.cn/s/blog_01ea595801013ig7.html
\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide,pgfplots}
\begin{document}
\begin{tikzpicture}[domain=0:4]
\tkzInit[xmax=4.2,ymax=4.2,xmin=-1.2,ymin=-3.2,xstep=1]
\tkzGrid
\tkzAxeXY
\draw[color=red] plot (\x,\x) node[right] {$f(x)=x$};
\draw[color=orange,domain=-0.5:4] plot (\x,{0.05*exp(\x)}) node[right] {$f(x)=\frac{1}{20}\mathrm e^x$};
\draw[color=blue,domain=0:4] plot (\x,{sin(\x r)}) node[right] {$f(x)=\sin x$};
\draw[color=blue!50,x=1cm,y=0.5cm,domain=-0.5:2.4] plot (\x, {(\x)^3-4*(\x)+2}) node[right] {$f(x)=x^3-4x+2$};
\end{tikzpicture}
\end{document}
%直接PDFLATEX编译即可
\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[x=.5cm,xmin=0,ymin=0]
\addplot[mark=none,smooth,red,thick] expression[domain=0:12]{exp(((x-6)^2)/(-9))};
\addplot[mark=none,smooth,blue,thick] expression[domain=1:19]{exp(((x-10)^2)/(-25))};
\addplot[mark=none,smooth,ultra thick] expression[domain=7.5:12]{exp(((x-6)^2)/(-9))};
\addplot[mark=none,smooth,ultra thick] expression[domain=1:7.5]{exp(((x-10)^2)/(-25))};
\addplot[dotted,mark=none]coordinates{(6,0)(6,1)};
\addplot[dotted,mark=none]coordinates{(10,0)(10,1)(0,1)};
\addplot[dashed,mark=none]coordinates{(7.5,0)(7.5,0.7788)(0,0.7788)};
\node[pin=-45:{$P$}] at (axis cs:0,0.7788) {};
\node[pin=135:{$P_x$}] at (axis cs:7.5,0) {};
\end{axis}
\end{tikzpicture}
\end{document}
%直接PDFLATEX编译即可
\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide,pgfplots}
\begin{document}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->,>=angle 90] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->,>=angle 90] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
%plot选项请看pgfmanual手册第224页
\draw[color=red] plot (\x,\x) node[right] {$f(x)=x$};
\draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x)=\frac{1}{20}\mathrm e^x$};
%下面的sin函数,要注意弧度和度数单位的转换,手册第225页
\draw[color=blue] plot (\x,{sin(\x r)}) node[right] {$f(x)=\sin x$};
\draw[color=blue,x=1cm,y=0.5cm,domain=-0.5:2.4] plot (\x, {(\x)^3-4*(\x)+2}) node[right] {$f(x)=x^3-4x+2$};
\end{tikzpicture}
\end{document}
from: http://blog.sina.com.cn/s/blog_01ea595801013ig7.html
相关文章推荐
- 设置div居中
- 摄影
- 编辑距离
- Linux C程序异常退出怎么办——core文件帮你忙
- 【Codewars】判断括号是否有效 validParentheses
- MySQL日志四种日志
- Linux 用户管理之用户管理与组管理
- 解决intellij idea新建maven项目,加载archetype模型很慢
- git当移动文件与更改文件共存Please enter a commit message to explain why this merge is necessary
- Ranklib部分源码分析
- OKHTTP通信使用(三)HTTPS
- Java关键字final、static使用总结
- Maven常用命令
- 傅里叶变换是用来做什么的,具体举例一下应用?
- 应用程序国际化
- objc_msgSend报错
- Android JAVA中去掉字符串空格的方法
- 5-19 支票面额 (15分)
- 测试用例编写标准
- sqlBASIC