LaTex 矢量绘图之 Tikz 代码示例汇总

2024-01-27 05:28

本文主要是介绍LaTex 矢量绘图之 Tikz 代码示例汇总,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1,代码

\documentclass[]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}\begin{tikzpicture} 
\draw (0,0) -- (1,1);%hello
\end{tikzpicture}\begin{tikzpicture} \draw[step=1,color=gray!40] (-2,-2) grid (2,2); \draw[->] (-3,0) -- (3,0); \draw[->] (0,-3) -- (0,3); \draw (0,0) circle (1);  
\end{tikzpicture} \begin{tikzpicture} \draw[help lines] ( -5,-5 ) grid ( 5, 5); 
\end{tikzpicture}\begin{tikzpicture} \draw[help lines] ( -5,-5 ) grid ( 5, 5); \draw[red] (-3,0) -- (3,0); \draw[red] (0,-3) -- (0,3); \end{tikzpicture}hello\\\begin{tikzpicture} \draw[->] (-3,3) -- (3,3); \draw[->>] (-3,2) -- (3,2); \draw[->|] (-3,1) -- (3,1); \draw[-to] (-3,0) -- (3,0); \draw[-latex] (-3,-1) -- (3,-1); \draw[-stealth] (-3,-2) -- (3,-2); \end{tikzpicture}\begin{tikzpicture} \draw[step=1,color=gray!40] (-2,-2) grid (2,2); \draw[->] (-3,0) -- (3,0); \draw[->] (0,-3) -- (0,3); \draw (0,0) circle (1);  \end{tikzpicture}\begin{tikzpicture} \draw[step=1,color=gray!40] (-2,-2) grid (2,2); \draw[->] (-3,0) -- (3,0); \draw[->] (0,-3) -- (0,3); \draw (0,0) ellipse (1 and 0.5); \end{tikzpicture}\begin{tikzpicture}\draw[step=1,color=gray!40] (-2,-2) grid (2,2);\draw[->] (-3,0) -- (3,0);\draw[->] (0,-3) -- (0,3);\draw[color=gray!40] (0,0) circle (1); %\draw[color=red] (1,0) arc (0:45:1);\draw[color=gray!40] (0,0) ellipse (1 and 0.5);\draw[color=green] (1,0) arc (0:60:1 and 0.5);\end{tikzpicture}\begin{tikzpicture}[scale=2]\draw[step=1,color=gray!40] (-2,-2) grid (2,2);\draw[color=red] (-1,-1) rectangle (1,1);\end{tikzpicture}hello\\\\\\\begin{tikzpicture}\draw[step=1,color=gray!40] (-2,-2) grid (2,2);\path (1,1) coordinate (p1);\coordinate (p2) at ( 2, 0);\draw[dotted, red] (p1) -- (p2)  ;\end{tikzpicture}\begin{tikzpicture}[scale=2]\draw[step=1,color=gray!40] (-2,-2) grid (2,2);\draw[latex-latex, red] (0,-2) -- ++(-1,1) -- ++(-1,-1);\draw[dashed, blue] (0,1) -- +(-1,1) -- +(-2,0);\end{tikzpicture}               
\\\\\\\\testtt\\\\\\\\\begin{tikzpicture} \node (node001) at (0,2) [draw] {test}; \end{tikzpicture}\begin{tikzpicture} \node (node001) at (0,2) [draw] {node001}; \node (node002) at (-2,0) [draw] {node002}; \node (node003) at (2,0) [draw] {node003}; \draw (node cs:name=node003,anchor=north) |- (0,1); \draw (node002.north) |- (0,1) -| (node cs:name=node001,anchor=south); \end{tikzpicture}
\\\\good    testtt\\\\\\\\\begin{tikzpicture} \node (p1) at (30:1) {$p_1$} ; \node (p2) at (75:1) {$p_2$} ; \draw (-0.2,0) -- (1.2,0) node[right] (xline) {$q_1$}; \draw (2,-0.2) -- (2,1.2) node[above] (yline) {$q_2$}; \draw[->] (p1) -- (p1 |- xline); \end{tikzpicture}\begin{tikzpicture} \node (p1) at (30:1) {$p_1$} ; \node (p2) at (75:1) {$p_2$} ; \draw (-0.2,0) -- (1.2,0) node[right] (xline) {$q_1$}; \draw (2,-0.2) -- (2,1.2) node[above] (yline) {$q_2$}; \draw[->] (p1) -- (p1 |- xline); \end{tikzpicture}
\\\\hello\\\\\begin{tikzpicture} \draw [ultra thick] (0,1) -- (2,1); \draw [thick] (0,0.5) -- (2,0.5); \draw [thin] (0,0) -- (2,0); \end{tikzpicture}
\\\\hello\\\\\\\\\begin{tikzpicture} \draw [line width=0.4pt] (0,0) -- (2,0); \draw[red]  (0,1) -- (2,1); \draw [line width=0.2cm] (4,.75) -- (5,.25); \end{tikzpicture}
\\\\hello\\\\\\\\\begin{tikzpicture}[scale=3] \draw[help lines] (0,0) grid (2,2); \draw[color=red] (0,0) .. controls (1,1) and (2,1) .. (2,0); \shade[ball color=gray!10] (0,0) circle (0.1); \shade[ball color=gray!40] (1,1) circle (0.1); \shade[ball color=gray!70] (2,1) circle (0.1); \shade[ball color=gray] (2,0) circle (0.1); \end{tikzpicture}\begin{tikzpicture} \shade[ball color=red] (1,2) circle (1); \end{tikzpicture}
\\\\hello\\\\\\\\
\begin{tikzpicture}[outline/.style={draw=#1,thick,fill=#1!50},outline/.default=black]\node [outline]at (0,1) {default};\node [outline=blue] at (0,0) {blue};\end{tikzpicture}
\\\\hello\\\\\\\\
\usetikzlibrary{positioning}
\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,
thick,inner sep=0pt,minimum size=6mm}}
\tikzset{transition/.style={rectangle,draw=black!50,
fill=black!20,thick,inner sep=0pt,minimum size=4mm}}
\tikzset{every label/.style=red}
\begin{tikzpicture}[bend angle=45]
\node[place] (waiting)  {};
\node[place] (critical) [below=of waiting] {};
\node[place](semaphore) [below=of critical,label=above:$s\le3$] {};
\node[transition](leave critical) [right=of critical]{};
\node[transition] (enter critical)[left=of critical]{};
\draw [->] (enter critical) to (critical);
\draw [->] (waiting) to [bend right] (enter critical);
\draw [->] (enter critical) to [bend right] (semaphore);
\draw [->] (semaphore) to [bend right] (leave critical);
\draw [->] (critical) to (leave critical);
\draw [->] (leave critical) to [bend right] (waiting);
\end{tikzpicture}
\\\\hello\\\\\\\\
\begin{tikzpicture}\draw[help lines] (0,0) grid (3,2);\foreach \x in {0,1,...,4}\draw[xshift=\x cm] (0,-1) -- (0,1);\end{tikzpicture}
\\\\hello\\\\\\\\
\begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); \draw (0,0) -- (1,1); \draw[red] (0,0) -- ([xshift=1cm] 1,1); \end{tikzpicture}
\\\\hello\\\\\\\\
\begin{tikzpicture} \draw (0,0)[rotate=30]  ellipse (2 and 1); \end{tikzpicture}
\\\\hello\\\\\\\\
\begin{tikzpicture} 
\begin{axis} 
\addplot{x*2}; 
\end{axis} 
\end{tikzpicture}
\\\\hello\\\\\\\\
\begin{tikzpicture}\begin{axis} \addplot coordinates  {(0,0) (1,1) (2,3) (3,9)}; \end{axis}\end{tikzpicture}
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\
\\\\hello\\\\\\\\\end{document}

2,效果示例

这篇关于LaTex 矢量绘图之 Tikz 代码示例汇总的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/649176

相关文章

Python函数作用域示例详解

《Python函数作用域示例详解》本文介绍了Python中的LEGB作用域规则,详细解析了变量查找的四个层级,通过具体代码示例,展示了各层级的变量访问规则和特性,对python函数作用域相关知识感兴趣... 目录一、LEGB 规则二、作用域实例2.1 局部作用域(Local)2.2 闭包作用域(Enclos

C++20管道运算符的实现示例

《C++20管道运算符的实现示例》本文简要介绍C++20管道运算符的使用与实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录标准库的管道运算符使用自己实现类似的管道运算符我们不打算介绍太多,因为它实际属于c++20最为重要的

Java中调用数据库存储过程的示例代码

《Java中调用数据库存储过程的示例代码》本文介绍Java通过JDBC调用数据库存储过程的方法,涵盖参数类型、执行步骤及数据库差异,需注意异常处理与资源管理,以优化性能并实现复杂业务逻辑,感兴趣的朋友... 目录一、存储过程概述二、Java调用存储过程的基本javascript步骤三、Java调用存储过程示

Visual Studio 2022 编译C++20代码的图文步骤

《VisualStudio2022编译C++20代码的图文步骤》在VisualStudio中启用C++20import功能,需设置语言标准为ISOC++20,开启扫描源查找模块依赖及实验性标... 默认创建Visual Studio桌面控制台项目代码包含C++20的import方法。右键项目的属性:

ModelMapper基本使用和常见场景示例详解

《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹

MySQL数据库的内嵌函数和联合查询实例代码

《MySQL数据库的内嵌函数和联合查询实例代码》联合查询是一种将多个查询结果组合在一起的方法,通常使用UNION、UNIONALL、INTERSECT和EXCEPT关键字,下面:本文主要介绍MyS... 目录一.数据库的内嵌函数1.1聚合函数COUNT([DISTINCT] expr)SUM([DISTIN

C++11作用域枚举(Scoped Enums)的实现示例

《C++11作用域枚举(ScopedEnums)的实现示例》枚举类型是一种非常实用的工具,C++11标准引入了作用域枚举,也称为强类型枚举,本文主要介绍了C++11作用域枚举(ScopedEnums... 目录一、引言二、传统枚举类型的局限性2.1 命名空间污染2.2 整型提升问题2.3 类型转换问题三、C

Java实现自定义table宽高的示例代码

《Java实现自定义table宽高的示例代码》在桌面应用、管理系统乃至报表工具中,表格(JTable)作为最常用的数据展示组件,不仅承载对数据的增删改查,还需要配合布局与视觉需求,而JavaSwing... 目录一、项目背景详细介绍二、项目需求详细介绍三、相关技术详细介绍四、实现思路详细介绍五、完整实现代码

Go语言代码格式化的技巧分享

《Go语言代码格式化的技巧分享》在Go语言的开发过程中,代码格式化是一个看似细微却至关重要的环节,良好的代码格式化不仅能提升代码的可读性,还能促进团队协作,减少因代码风格差异引发的问题,Go在代码格式... 目录一、Go 语言代码格式化的重要性二、Go 语言代码格式化工具:gofmt 与 go fmt(一)

C++ 检测文件大小和文件传输的方法示例详解

《C++检测文件大小和文件传输的方法示例详解》文章介绍了在C/C++中获取文件大小的三种方法,推荐使用stat()函数,并详细说明了如何设计一次性发送压缩包的结构体及传输流程,包含CRC校验和自动解... 目录检测文件的大小✅ 方法一:使用 stat() 函数(推荐)✅ 用法示例:✅ 方法二:使用 fsee