文章目录

  • 基础环境
    • 单行
    • 子域
    • 环境
    • 包围
  • 坐标
    • 标准
    • 单位
    • 相对
    • 记录
    • 极坐标
    • 计算
  • 箭头
  • 图形
    • 三角
    • 矩形
    • 网格
  • 函数
    • 抛物线
    • 三角
    • 贝塞尔曲线
    • 连线
    • 函数
      • node
      • plot
    • 坐标系
  • 填充
    • 渐变
  • node
    • 偏移
    • 名称
    • 形状
    • 填充
    • 相对
    • 融合
  • 路径
    • 线段
    • 图形
    • 其他

基础环境

\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}\begin{tikzpicture}\draw (0,0) -- (1,1);\end{tikzpicture}
\end{document}

#命令环境

单行

\tikz \draw (0,0) -- (1,1); % 每次绘图,以;结尾

子域

\tikz {\draw (0,0) -- (1,1); \draw (0,1) -- (1,0);}

环境

\begin{tikzpicture}\draw (0,0) -- (1,1);\draw (0,1) -- (1,0);
\end{tikzpicture}

后续统一以此中方式进行说明

\begin{tikzpicture}[domain=-3:3] % 规划画布大小
\end{tikzpicture}

包围

\tikzpicture\draw (0,0) -- (1,1);\draw (1,0) -- (0,1);
\endtikzpicture

坐标

标准

\begin{tikzpicture}\drarw (0,0) -- (1,1); % 默认的画图单位为cm
\end{tikzpicture}

单位

\begin{tikzpicture}\draw (0pt, 0pt) -- (1pt, 1pt); % 图像显示可以明确的感受到尺度差异
\end{tikzpicture}

相对

\begin{tikzpicture}\draw (0,0) -- +(1,1); % (0,0) -- (0+1,0+1)\draw (1,2) -- +(1,1); % (1,2) -- (1+1,2+1)
\end{tikzpicture} % 可以使用相对坐标进行偏移

记录

\begin{tikzpicture}\draw (0,0) -- +(1,1) -- +(0,1); % (0,0) -- (0+1,0+1) -- (0+0,0+1);% 偏移总是以上一次的记录值为准\draw (0,0) -- ++(1,1) -- +(0,1); %(0,0) -- (0+1,0+1) -- (0+1+0, 0+1+1)% 使用++,表示偏移,且更新上一次记录值
\end{tikzpicture}

极坐标

\begin{tikzpicture}\draw (0:1) -- (90:1) -- (180:1) -- (270:1) -- (360:1);% (angle, length); 天然支持极坐标
\end{tikzpicture}
\begin{tikzpicture}% 两种坐标天然混杂,自动区分\draw (0,0) -- (0:1) -- (1,1) -- (90:1) -- (0,0);
\end{tikzpicture}

计算

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc} % 引入计算支持
\begin{document}\begin{tikzpicture}\draw (1,3) -- ($3*(1,3) - (-2, 5)$); % (1,3) -- (5, 4)% 1. 计算内容使用$$包含% 2. 进行坐标整体计算,而不是单个部分\end{tikzpicture}
\end{document}
\begin{tikzpicture}
\draw (0:1) -- ($(90:100) - (0, 99)$); % 极坐标同样支持计算
\end{tikzpicture}

箭头

\begin{tikzpicture}\draw [->]    (0,0) -- (3,0);\draw [<-]    (0,1) -- (3,1);\draw [<->]   (0,2) -- (3,2);\draw [|->]   (0,3) -- (3,3);\draw [>->>]  (0,4) -- (3,4);\draw [|<->|] (0,5) -- (3,5);
\end{tikzpicture}

图形

三角

\begin{tikzpicture}\draw (0,0) -- (0,3) -- (4,0) -- cycle; % cycle 用来填充缺口
\end{tikzpicture}
\begin{tikzpicture}[line width=3pt]\draw (0,0) -- (0,3) -- (4,0) -- (0,0); % 有缺口\draw (5,5) -- (5,8) -- (9,5) -- cycle; % cycle 用来填充缺口
\end{tikzpicture}

矩形

\begin{tikzpicture}\draw (0,0) rectangle (3,3); % 两个点围成的矩形
\end{tikzpicture}

网格

\begin{tikzpicture}\draw [step=1] (0,0) grid (5,5); % 从两点规划矩形,然后按照步长进行分割
\end{tikzpicture}

\begin{tikzpicture}\draw (3,3) circle (2); % 中心坐标(3,3), 半径为2,外接矩形为 2x2\draw (3,3) ellipse (3 and 2); % 椭圆,后参数分为(x, y)轴长
\end{tikzpicture}

\begin{tikzpicture}\draw (3,3) arc (0:180:2); % 上图圆上半部分\draw (3,3) arc (180:360:3 and 2); % 上图椭圆下半部分% 图形图像不变,但是原来的坐标变为了弧线的起始点% 角度按照逆时间方向进行计算
\end{tikzpicture}

函数

抛物线

\begin{tikzpicture}\draw (1,1) parabola (3,3); % 默认以起始点为极值点\draw (2,1) parabola[bend at end] (4,3); % bend at end: 终点为极值点\draw (0,0) parabola bend (3,5) (5,4); % bend:中指定极值点
\end{tikzpicture}

三角

\begin{tikzpicture}\draw (0,0) sin (1,1); % sin 右极值\draw (1,0) cos (2,1); % cos 左极值\draw (2,0) cos (4,2) sin (6,0); % 为了衔接极值点,极值点总是左边sin右边cos% 同样的,极值点的转换部分,总是左边cos右边sin,否则曲线不够光滑% 因为不能两端都是极值点
\end{tikzpicture}

贝塞尔曲线

\begin{tikzpicture}\draw (0,0) .. controls (1,1) .. (4,0); % draw start .. controls ctrl .. end;\fill (1,1) circle (1pt); % fill 填充图像
\end{tikzpicture}

二次贝塞尔曲线,首尾两端切线都过指定点

\begin{tikzpicture}\draw (0,0) .. controls (1,1) and (3,-1) .. (4,0); % ctrl: A and B\fill (1,1) circle (1pt);\fill (3,-1) circle (1pt);
\end{tikzpicture}

三次就是两个控制点

连线

\begin{tikzpicture}\draw (0,0) to (4,0); % 同 --, 默认情况下直线相连\draw (0,0) to[out=60,in=-120] (4,0);% out: 出线角度% in : 收线角度
\end{tikzpicture}

函数

\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}\begin{tikzpicture}[domain=-3:3]\draw [->] (-3.5,0) -- (3,0) node[below] {$x$};             % x轴\draw [->] (0,-3.5) -- (0, 3.5) node[above] {$f(x)$};    % y轴\fill (0,0) circle (3pt);                                                           % 原点\draw [step=1,color=gray] (-3,-3) grid (3,3);                 % 网格\draw [color=orange] plot (\x, \x);                                    % y = x\draw [color=red] plot (\x, {\x^2 / 3});                           % y = x ^ 2 / 3\draw [color=cyan] plot (\x, {3 * sin(\x r)});                 % y = 3 sin(x)\end{tikzpicture}
\end{document}

node


node[direction] symbol; % 后续进行说明

plot

\draw [color=color] plot (x, y); % 其中\x表示符号
  • 如果是复杂计算式,包含括号,则需要使用{}进行包含
  • 三角运算,以角度计算,应该转化为弧度\x r

坐标系

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\newenvironment{axis}[1]
{   % 坐标系环境定义\begin{tikzpicture}[domain=-#1:#1]\draw ($(-#1,0)-(0.5,0)$) -- ($(#1,0)+(0.5,0)$) node[below] {$x$};\draw ($(0,-#1)-(0,0.5)$) -- ($(0,#1)+(0,0.5)$) node[above] {$f(x)$};\fill (0,0) circle (1pt);\draw [step=1, color=gray] (-#1,-#1) grid (#1,#1);
}
{\end{tikzpicture}}
\begin{document}\begin{axis}{3}\draw [color=red] plot (\x, {sin(\x r)})\end{axis}
\end{document}

填充

\begin{tikzpicture}% 画图,仅仅描绘边框\draw [blue] (0,0) rectangle (1,1);\draw [green] (3,3) circle (1);% 填充,仅仅填充颜色\fill [green] (0,0) rectangle (1,1);\fill [blue] (3,3) circle (1);% 双管齐下\filldraw[fill=yellow, draw=red] (2,2) circle (1);
\end{tikzpicture}

渐变

\begin{tikzpicture}\shade [inner color=yellow, outer color=orange] (2,2) circle (1);% inner % outer\shade [left color=blue,right color=green] (3,3) rectangle (1,1);% left% right% top% bottom% 可填充着六个维度,一般选择一对即可,颜色太多并没有想要的效果
\end{tikzpicture}

node

偏移

\begin{tikzpicture}
\fill (0,0) circle (1pt);
\node[above] at (0,0) {$A$}; % \node[direction] at (location) {$label$};
\node[below] at (0,0) {$B$}; % 上下左右=>(above, below, left, right)
\node[left]  at (0,0) {$L$};
\node[right] at (0,0) {$R$};
\end{tikzpicture}

名称

\begin{tikzpicture}% 指定点放置标签\node (a) at (2,1)  {$A$};\node (b) at (2,-1) {$B$};\node (l) at (1,0)  {$L$};\node (r) at (3,0)  {$R$};% 标签可以按照点一样连线\draw[->,color=orange] (a) -- (l);\draw[->,color=green]  (l) -- (b);\draw[->,color=blue]   (b) -- (r);\draw[->,color=cyan]   (r) -- (a);
\end{tikzpicture}

形状

\begin{tikzpicture}\node [shape=circle] (a) at (0,0) {$C$};         % circle\node [shape=rectangle] (b) at (1,1) {$R$};        % rectangle, 默认为矩形\node [shape=coordinate] (c) at (2,2) {$P$}; % coordinate\draw[->] (a) -- (b) -- (c); % coordinate无区域,会覆盖任何标签
\end{tikzpicture}

填充

\begin{tikzpicture}\node [fill=gray] at (0,0) {$F$};
\end{tikzpicture}

相对

% \usetikzlibrary{position}
\begin{tikzpicture}
\node [fill=orange] (a) at (0,0) {$A$};
\node [fill=red, right=4 of a ] (b) {$B$}; % 根据已有的node,直接通过相对位置指定和位移即可定位
\node [fill=blue, above left=2 of b] (c) {$C$};
\draw (a) -- (b) -- (c) -- (a);
\end{tikzpicture}

\usetikzlibrary{position}千万不能忘记!

融合

\begin{tikzpicture}\draw (0,0) node[above right] {$A$} -- (3,0) node[right] {$B$} -- (0,4) node[above]{$C$} -- cycle;% 点后面直接可以跟node% 同样可以设置属性和标签% 相对位置为点的坐标
\end{tikzpicture}

路径

线段

\begin{tikzpicture}\path[draw] (0,0) -- (1,1); % draw: 画路径
\end{tikzpicture}

图形

\begin{tikzpicture}\path[draw=cyan, fill=yellow] (0,0) -- (3,0) -- (0,3) -- cycle; % draw: 连线% fill: 填充
\end{tikzpicture}

其他

\begin{tikzpicture}
% draw, shade
\path[draw=black, inner color=yellow, outer color=orange] (3,3) circle (1);
% fill
\path[fill=blue] (2,2) rectangle (1,1);
% shade
\path[left color=red, right color=green] (0,0) .. controls (1,1) and (3,3) .. (6,0);
\path[fill](3,3) circle(1pt);
\path[fill](2,2) circle(1pt);
% node
\path[fill=gray](3,3) node[below] (a) {$P$};
\end{tikzpicture}

latex-tikz简单绘图相关推荐

  1. 【TikZ 简单学习(下):基础绘制】Latex下的绘图宏包

    [TikZ 简单学习[下]:基础绘制]Latex下的绘图宏包 上文 绘制多个节点 给节点添加统一样式 给节点命名 使用相对位置绘制 给节点标签 链接边的绘制 在线边上添加标签 绘制蛇形线和多行文本 层 ...

  2. python绘图实例-Python使用matplotlib简单绘图示例

    本文实例讲述了Python使用matplotlib简单绘图.分享给大家供大家参考,具体如下: # -*- coding:utf-8 -*- #! python2 """ ...

  3. 简单python脚本实例画图-Python使用matplotlib简单绘图示例

    本文实例讲述了Python使用matplotlib简单绘图.分享给大家供大家参考,具体如下: # -*- coding:utf-8 -*- #! python2 """ ...

  4. mac下简单绘图工具

    mac下简单绘图工具 由于用的Mac系统的缘故,有时候想绘制一些简单的图形,想找一款像window下的画图工具,一直没有找到 今天无意中想到了一个方法,使用Mac系统自带的"预览" ...

  5. c# GDI+简单绘图(一)

    最近对GDI+这个东西接触的比较多,也做了些简单的实例,比如绘图板,仿QQ截图等. 最早接触这个类,是因为想做仿QQ截图的效果.巧的很,学会了如何做截图后,.NET课堂上老师也正巧要讲关于c#绘图方面 ...

  6. 一个用于提取简体中文字符串中省,市和区并能够进行映射,检验和简单绘图的python模块...

    简介 一个用于提取简体中文字符串中省,市和区并能够进行映射,检验和简单绘图的python模块. 举个例子: ["徐汇区虹漕路461号58号楼5楼", "泉州市洛江区万安塘 ...

  7. VC学习笔记:简单绘图

    VC学习笔记:简单绘图 SkySeraph Oct.29th 2009  HQU Email-zgzhaobo@gmail.com  QQ-452728574 Latest Modified Date ...

  8. 用java实现简单绘图

    用java实现简单绘图的过程中可以让初学者更好的学习java这门语言,更好的理解包括变量类型,类与对象,接口等概念.在学习了简单的Swing程序设计之后,初学者可以运用窗体框架JFrame,布局管理器 ...

  9. Java图形编程实验总结_JAVA实验报告简单绘图程序

    <JAVA实验报告简单绘图程序>由会员分享,可在线阅读,更多相关<JAVA实验报告简单绘图程序(8页珍藏版)>请在人人文库网上搜索. 1.实验三绘制图形一.实验目的学会JBut ...

  10. CAD看图软件也可以简单绘图吗?

    今天给大家详细讲解下CAD看图软件在看图的同时,也可以简单绘图的哦!具体编辑功能如下:从左到右依次是CAD画线.CAD测量.CAD标注.CAD删除,撤销(上一步)和重做. 1.CAD画线 点击[画线] ...

最新文章

  1. 我学UML建模系列之核心元素 -------- 参与者
  2. Java输入光标在printf前面_C++ 设置控制台(命令行)窗口 光标位置,及前背景颜色
  3. java二维矩阵怎么进行转置_矩阵求导的本质与分子布局、分母布局的本质(矩阵求导——本质篇)...
  4. [vue] 说说你对SPA单页面的理解,它的优缺点分别是什么?
  5. Anaconda中软件库更新
  6. java jpanel 叠加_java – 如何在JPanel上叠加,调整大小和居中组件?
  7. vi/vim: 文件浏览和缓冲区浏览
  8. iOS开发小技巧 -- tableView-section圆角边框解决方案
  9. Android测试点和测试工具介绍
  10. 关于飞思卡尔MSCAN滤波器的理解
  11. kali启动ssh服务后,依然无法连接的问题。
  12. sort 自定义排序使用方法
  13. 构建单拷贝同源蛋白系统发育树,一条命令提序列!
  14. 创业:房多多--如何成功从红海杀出一片天空
  15. PV,V,UV的概念,采集数据
  16. 互联网的前世今生:Web 1.0、2.0、3.0
  17. EDGE浏览器关闭网址栏自动补全
  18. 追风筝的人 第九章
  19. 标准化和归一化 超全详解
  20. 微软、IBM联合开拓移动办公市场 PK苹果?

热门文章

  1. android的UI组件实验,实验一 Android Activity及UI设计.doc
  2. Type Qualifier
  3. gitHub资源快速访问方法--jsDeliver
  4. 2021年内蒙古高考成绩查询一分一段,2021年内蒙古高考成绩排名及一分一段表
  5. thymeleaf 点击按钮跳转页面_spring boot使用thymeleaf跳转页面实例代码
  6. PHP+vue房屋租赁系统 在线租房系统
  7. 漫谈深度强化学习之基础概念
  8. tar解压单个/部分文件
  9. php公告栏系统,不间断上下循环滚动的公告栏效果
  10. java判断集合是否存在交集