latex-pgfplots基础绘图

基础环境

\documentclass[tikz]{stanalone}	% 
\usepackage{pgfplots}						% 包导入
\begin{document}
	\begin{tikzpicture}						% 画板
		\begin{axis}								% 坐标
			content...
		\end{axis}
	\end{tikzpicture}
\end{document}

后续均默认次模板,书写范围从axis算起

\begin{axis}
	content...
\end{axis}

有特殊说明会进行提示。

一般图像

折线图

\begin{axis}[sharp plot] % sharp plot: 折线图,通过修改此类型,即可完成多种图形绘制
	\addplot coordinates{
		(0,1)
    (1,3)
    (2,4)
    (3,1)
    (4,5)
    (5,2)
	};
	% addplot: 添加绘图
	% coordinates: 点坐标,无需分隔符
\end{axis}

光滑曲线

\begin{axis}[smooth] % smooth: 光滑曲线
	\addplot coordinates{
		(0,1)
    (1,3)
    (2,4)
    (3,1)
    (4,5)
    (5,2)
	};
\end{axis}

条形图

\begin{axis}[ybar,enlargelimits=0.25] % ybar: 条形图, enlargelimits: 柱子之间最大间隔
	% 可以控制图像属性
	\addplot[draw=yellow, fill=orange] coordinates{
		(0,1)
    (1,3)
    (2,4)
    (3,1)
    (4,5)
    (5,2)
	};
	% 可以进行多个图像同意坐标系的绘制
	\addplot[draw=blue, fill=green] coordinates{
    (0,1)
    (1,3)
    (2,4)
    (3,1)
    (4,5)
    (5,2)
	};
\end{axis}

在这里插入图片描述

同坐标会自动编排。

直方图

\begin{axis}[ybar interval]			% ybar interval: 连续柱形图?好像式直方图的养足
\addplot[fill=red,hist={bins=9}]% hist设置分组为9
table[row sep=\\,y index=0] { 	% row sep: 数据行分隔符, y index: 从0开始计
	data\\												% data: 单行数据名称,内部自动映射
	1\\
	2\\2\\
	3\\3\\3\\
	4\\4\\4\\4\\
	5\\5\\5\\5\\5\\
	6\\6\\6\\6\\
	7\\7\\7\\
	8\\8\\
	9\\
};
\end{axis}

在这里插入图片描述

函数图像

二维

\begin{axis}[domain=-10:10,axis x line=center, axis y line=center]
	% domain: 定义域
	% axis x line: x轴
	% axis y line: y轴
	\addplot {x};				% y = x
	\addplot {1.5^x };	% y = 1.5 ^ x
\end{axis}

在这里插入图片描述

三维

\begin{axis}[colorbar] 	% colorbar: 显示彩色指示条
\addplot3[surf]					% 三维绘图
{x^2 + y^2};						% 函数式
\end{axis}

在这里插入图片描述

补充

\begin{axis}[domain=-pi:pi, title=this is title, hide axis,legend pos=outer north east]
% domain: 定义域
% title:	标题
% hide axis:隐藏坐标系
% legend pos: 图例位置
\addplot {sin(deg(x))};						% deg: 转弧度
\addlegendentry{$f(x) = sin(x)$}	% 图例:f(x) = sin(x)
\addplot {cos(deg(x))};						% 
\addlegendentry{$f(x) = cos(x)$};	% 图例:f(x) = cos(x)
\end{axis}

在这里插入图片描述

帽子

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}	% 颜色
\begin{document}
	\begin{tikzpicture}
		\begin{axis}[
		domain=-8:8,									% 定义域
		title=hat,										% 标题
		hide axis,										% 隐藏坐标
		colormap/cool,								% 引入的颜色
		]
		\addplot3[mesh, samples=50]{	% 网格
		% $f(x, y) = \frac{\sqrt{x^2 + y^2}}{\sqrt{x^2 + y^2}}$
		sin(deg(sqrt(x^2+y^2)))	 / sqrt(x^2+y^2)};
		% legend
		\addlegendentry{$f(x)=\frac{sin(r)}{r} \quad r = \sqrt{x^2 + y^2}$ },;
		\end{axis}
	\end{tikzpicture}
\end{document}

在这里插入图片描述

  • 7
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
LaTeX-OCR是一个基于OCR技术的开源项目,旨在将LaTeX公式转换为电子文本。CSDN是中国最大的IT社区和技术知识分享平台。 LaTeX是一种常见的排版软件,主要用于科技论文、学术文章、书籍和报告的编写。它具有专业的排版效果和强大的数学公式编辑功能。然而,LaTeX语法相对复杂,对于不熟悉LaTeX的人来说,编辑和理解LaTeX公式可能会有一定的困难。 LaTeX-OCR项目的目标是利用OCR技术的优势,将印刷体的LaTeX公式转化为可编辑的电子文本。这个项目使用机器学习和计算机视觉算法,通过训练模型来自动识别LaTeX公式中的字符和结构,并将其转换为标准的LaTeX语法。这样,用户就可以通过扫描或拍照的方式将纸质文档中的LaTeX公式转换为可编辑的电子文本。 CSDN是中国IT技术社区的领导者,这个平台提供了丰富的技术文章、教程和在线问答。LaTeX-OCR项目在CSDN上发布了相关的教程和应用案例,帮助用户了解如何使用这个项目来解决LaTeX公式识别的问题。用户可以通过CSDN平台学习LaTeX-OCR的原理和使用方法,并与其他开发者交流经验和解决方案。 总之,LaTeX-OCR是一个将LaTeX公式转化为电子文本的开源项目,而CSDN是一个为技术爱好者提供知识分享和交流的平台。通过LaTeX-OCR项目和CSDN平台,用户可以更加方便地处理LaTeX公式,提高工作和学习的效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值