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中logging模块用法示例总结

《Python中logging模块用法示例总结》在Python中logging模块是一个强大的日志记录工具,它允许用户将程序运行期间产生的日志信息输出到控制台或者写入到文件中,:本文主要介绍Pyt... 目录前言一. 基本使用1. 五种日志等级2.  设置报告等级3. 自定义格式4. C语言风格的格式化方法

Spring 中的切面与事务结合使用完整示例

《Spring中的切面与事务结合使用完整示例》本文给大家介绍Spring中的切面与事务结合使用完整示例,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考... 目录 一、前置知识:Spring AOP 与 事务的关系 事务本质上就是一个“切面”二、核心组件三、完

sky-take-out项目中Redis的使用示例详解

《sky-take-out项目中Redis的使用示例详解》SpringCache是Spring的缓存抽象层,通过注解简化缓存管理,支持Redis等提供者,适用于方法结果缓存、更新和删除操作,但无法实现... 目录Spring Cache主要特性核心注解1.@Cacheable2.@CachePut3.@Ca

QT Creator配置Kit的实现示例

《QTCreator配置Kit的实现示例》本文主要介绍了使用Qt5.12.12与VS2022时,因MSVC编译器版本不匹配及WindowsSDK缺失导致配置错误的问题解决,感兴趣的可以了解一下... 目录0、背景:qt5.12.12+vs2022一、症状:二、原因:(可以跳过,直奔后面的解决方法)三、解决方

MySQL中On duplicate key update的实现示例

《MySQL中Onduplicatekeyupdate的实现示例》ONDUPLICATEKEYUPDATE是一种MySQL的语法,它在插入新数据时,如果遇到唯一键冲突,则会执行更新操作,而不是抛... 目录1/ ON DUPLICATE KEY UPDATE的简介2/ ON DUPLICATE KEY UP

Python中Json和其他类型相互转换的实现示例

《Python中Json和其他类型相互转换的实现示例》本文介绍了在Python中使用json模块实现json数据与dict、object之间的高效转换,包括loads(),load(),dumps()... 项目中经常会用到json格式转为object对象、dict字典格式等。在此做个记录,方便后续用到该方

MySQL分库分表的实践示例

《MySQL分库分表的实践示例》MySQL分库分表适用于数据量大或并发压力高的场景,核心技术包括水平/垂直分片和分库,需应对分布式事务、跨库查询等挑战,通过中间件和解决方案实现,最佳实践为合理策略、备... 目录一、分库分表的触发条件1.1 数据量阈值1.2 并发压力二、分库分表的核心技术模块2.1 水平分

SpringBoot请求参数传递与接收示例详解

《SpringBoot请求参数传递与接收示例详解》本文给大家介绍SpringBoot请求参数传递与接收示例详解,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋... 目录I. 基础参数传递i.查询参数(Query Parameters)ii.路径参数(Path Va

RabbitMQ 延时队列插件安装与使用示例详解(基于 Delayed Message Plugin)

《RabbitMQ延时队列插件安装与使用示例详解(基于DelayedMessagePlugin)》本文详解RabbitMQ通过安装rabbitmq_delayed_message_exchan... 目录 一、什么是 RabbitMQ 延时队列? 二、安装前准备✅ RabbitMQ 环境要求 三、安装延时队

Redis实现高效内存管理的示例代码

《Redis实现高效内存管理的示例代码》Redis内存管理是其核心功能之一,为了高效地利用内存,Redis采用了多种技术和策略,如优化的数据结构、内存分配策略、内存回收、数据压缩等,下面就来详细的介绍... 目录1. 内存分配策略jemalloc 的使用2. 数据压缩和编码ziplist示例代码3. 优化的