Latex学习笔记 (Ex1) 绘制数学图表

使用LaTeX绘制图片
在上篇文章 根据几何定义使用计算机编程求定积分的值 中,引用了下面一张图,这张图是使用 TikZ 绘制的,为方便阅读,所有的 LaTeX \LaTeX LATEX 源代码也一半放出。
在这里插入图片描述

\documentclass[9pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
  
\begin{document}
\begin{tikzpicture}[scale=2]
\begin{axis}[
	title={A demonstration of calculate integration.},
	axis x line = middle,
	axis y line = middle,
	xmin=-0.2, xmax=1.6,
	ymin=-0.2, ymax=1.2,
	xtick={1},
	ytick={0, 1},
	% xstep=1,ystep=1,
	very thin, 
	width=6cm,
	height=6cm,
	trig format plots=rad,
	variable=x]

\fill[gray!20, domain=0:1, variable=\x]  (0, 0)  -- plot ({\x}, {\x*\x})  -- (1, 1)  -- (1,0) -- cycle;
\fill[blue!20!white] (0.5,0) rectangle (0.7,0.25);	
\fill[red!40!white] (0.5, 0.25) -- (0.7, 0.25) -- (0.7, 0.49) -- cycle;

\addplot[red,very thin,domain=-1:3,samples=200] (x, x^2);
\draw[very thin] (0,0) -- (7,0);
\draw[very thin] (1,0) -- (1,1);
\draw[very thin] (0.5,0.25) -- (0.7,0.25);
\draw[very thin] (0.5,0) -- (0.7,0) -- (0.7,0.49) -- (0.5, 0.25) -- cycle;
\draw (0.5,1) node {$y=x^2$};  
\draw (0.5,-0.1) node {$x_i$}; 
\draw (0.36,0.3) node {$f(x_i)$}; 
\draw (0.8,-0.1) node {$x_{i+1}$};
\draw (0.7,0.49) -- (0.45,0.65) node[fill=white] {$f(x_{i+1})$};
\draw (0.85, 0.25) -- (1.3, 0.5) node[fill=white] {$\int_0^1 x^2 \mathrm{d}x$};
\end{axis}
\end{tikzpicture}
\end{document}
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值