LaTeX——tikz学习(1)——基本内容学习

一、参考资料

链接: LaTeX 绘图指南 - 001TikZ 的简介、资源以及学习方法
链接: LaTeX—Tikz 宏包入门使用教程
链接: PGF文件是LeTaX文件中的矢量图形

二、前置准备

1、主文件加载tikz宏包,下面就可以使用宏包的对应命令
在这里插入图片描述
TikZ宏包是一个十分强大的绘图宏包,它提供\tikz 命令和tikzpicture 环境
2、具体绘图指令可以放在\tikz 后面,也可以放在tikzpicture 中间。

\tikz ... 


\begin{tikzpicture}
...
\end{tikzpicture}

三、绘图练习

1、直线、圆、弧

在这里插入图片描述

%% 正文 %%
\begin{document}


% 直线、圆、弧
\begin{preview}
    \begin{tikzpicture}
        \draw[rounded corners] (0,0) rectangle (10,5);
        \draw[-] (0,0) -- (10,0) node[below] {$X$};
        \draw[-] (0,0) -- (0,5) node[left] {$Y$};
        \draw[rounded corners] (0,1) -- (1,0) -- (3,2);
        % 非真正的封闭图形,部分圆角
        \draw[rounded corners] (3,1) -- (4,0) -- (6,2) -- (3,1);
        % 真正的封闭图形,全圆角
        \draw[rounded corners] (6,1) -- (7,0) -- (9,2) -- cycle;

        \draw (1,4) circle (1);
        % 角度从右侧开始
        %\draw (3,4) arc (0:90:1);
        \draw (4,4) ellipse (2 and 1);
        \draw (8,4) arc (90:180:2 and 1);% 此时(8,4)为绘图起点而非椭圆中心
    \end{tikzpicture}
\end{preview}

\end{document}

2、曲线

% 曲线种类疑似不同,顶点间距同,效果不同
        \draw (0,1) .. controls (2,0) .. (3.414,2);
        \draw (3,1) parabola bend (4,0) (5.414,2);% 抛物线

在这里插入图片描述

% 2、曲线
\begin{preview}
    \begin{tikzpicture}
        \draw (0,0) rectangle (10,5);
        \draw[-] (0,0) -- (10,0) node[below] {$X$};
        \draw[-] (0,0) -- (0,5) node[left] {$Y$};
        \draw [help lines] (0,0) grid (10,5);
        % 曲线种类疑似不同,顶点间距同,效果不同
        \draw (0,1) .. controls (2,0) .. (3.414,2);
        \draw (3,1) parabola bend (4,0) (5.414,2);% 抛物线
        \filldraw (0,1) circle (.1)
        (2,0) circle (.1)
        (3.414,2) circle (.1)
        (3,1) circle (.1)
        (4,0) circle (.1)
        (5.414,2) circle (.1);
    \end{tikzpicture}
\end{preview}

3、箭头、填充

在这里插入图片描述

\begin{preview}
    \begin{tikzpicture}
        \draw[->,line width=1pt] (0,0) -- (10,0) node[below] {$X$};
        \draw[->,thick] (0,0) -- (0,5) node[left] {$Y$};
        \draw (0,0) rectangle (1,2);
        %shift平移
        \draw[shift ={(2,0)},color=red] (0,0) rectangle (1,2);
        %scale缩放
        \draw[scale=1.5,color=blue] (0,0) rectangle (1,2);
        %rotate默认对起点旋转,这里是矩形左下点
        \draw[xshift=125pt,color=green,rotate=25] (0,0) rectangle (1,2);
        %定点旋转
        \draw[shift ={(2,0)},rotate around={25:(1,2)},color=yellow] (0,0) rectangle (1,2);
        %slant倾斜
        \draw[xshift=185pt,xslant=0.2](0,0) rectangle (1,2);

        \draw[red] (0,4) -- (1,4);
        \draw[green] (1,4) -- (2,4);
        \draw[blue] (2,4) -- (3,4);
        % draw和fill不填默认为黑色,!数字表示颜色的程度
        \filldraw[draw=blue!80,fill=blue!20] (5,4) circle (1);
        \draw[blue] (7,4) circle (1);
    \end{tikzpicture}
\end{preview}

4、示意图

在这里插入图片描述

预先设置box格式

% 预先设置流程图框box
\tikzset{
box/.style ={
rectangle,
rounded corners = 5pt,
minimum width = 50pt,
minimum height = 20pt,
inner sep = 5pt,
draw = blue
}
}
\begin{preview}
    \begin{tikzpicture}
        % 预先设置box
        \node[box] (1) at(0,0) {1};
        \node (2) at(4,0) {2};
        \node[box] (3) at(8,0) {3};
        \draw[->] (1)--(2);
        \draw[->] (2)--(3);
        \node at(2,1) {a};
        \node at(6,1) {b};
    \end{tikzpicture}
\end{preview}
% 树
\begin{preview}
    \begin{tikzpicture}[sibling distance = 80pt]%控制兄弟间距
        \node[box]{1}
            child{node[box] {2}}
            child{node[box] {3}
                child{node[box] {4}}
                child{node[box] {5}}
                child{node[box] {6}}
            };
    \end{tikzpicture}
\end{preview}

5、函数

在这里插入图片描述

\begin{preview}
    \begin{tikzpicture}
        \draw[->] (0,0)--(5,0) node[right] {$X$};
        \draw[->] (0,0)--(0,5) node[above] {$Y$};
    \draw[domain = 0:4] plot (\x,{0.1* exp(\x)}) node[right] {
    $Y=\frac{1}{10}e^x$};
    \end{tikzpicture}
\end{preview}

6、曲线拟合

曲线拟合:根据离散的数据点绘制的曲线
plot函数
链接: tikz曲线拟合
该图像函数寻找出处:irregular curve
链接: How to use ‘controls’ with closed curves like ‘circle’ or ‘ellipse’ to produce irregular closed curves

在这里插入图片描述

\begin{preview}
    \begin{tikzpicture}
        \def\A{(3,3.5) (4,4.5) (5,4.8) (6,4.7) (7,4) (6,3) (3.5,2.8)}
        \draw[red] plot[smooth cycle] coordinates {\A};%加上smooth曲线平滑,没有尖角
    \end{tikzpicture}
\end{preview}
		%1%\coordinate (A) at (3,3.5);
        %\coordinate (B) at (5,4.5);
        %\coordinate (C) at (7,4);
        %\coordinate (D) at (6,3);
        %\coordinate (E) at (3.5,2.8);
        %\draw plot[smooth cycle] coordinates{(A)(B)(C)(D)(E)};%加上smooth曲线平滑,没有尖角
		
		%2:
        \def\A{(3,3.5) (4,4.5) (5,4.8) (6,4.7) (7,4) (6,3) (3.5,2.8)}
        %线条细的效果没弄出来
        \draw[very thin] plot[smooth cycle] coordinates {\A};%加上smooth曲线平滑,没有尖角
        \draw[-] (6,4)--(7,5) node[above] {$\phi(x,y,z) = a$};

7、常用数字符号

链接: latex数学符号汇总

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值