当前位置:   article > 正文

LaTex 矢量绘图之 Tikz 代码示例汇总_latex tikz 画二维图

latex tikz 画二维图

1,代码

  1. \documentclass[]{article}
  2. \usepackage{tikz}
  3. \usepackage{pgfplots}
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \draw (0,0) -- (1,1);%hello
  7. \end{tikzpicture}
  8. \begin{tikzpicture}
  9. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  10. \draw[->] (-3,0) -- (3,0);
  11. \draw[->] (0,-3) -- (0,3);
  12. \draw (0,0) circle (1);
  13. \end{tikzpicture}
  14. \begin{tikzpicture}
  15. \draw[help lines] ( -5,-5 ) grid ( 5, 5);
  16. \end{tikzpicture}
  17. \begin{tikzpicture}
  18. \draw[help lines] ( -5,-5 ) grid ( 5, 5);
  19. \draw[red] (-3,0) -- (3,0);
  20. \draw[red] (0,-3) -- (0,3);
  21. \end{tikzpicture}
  22. hello\\
  23. \begin{tikzpicture}
  24. \draw[->] (-3,3) -- (3,3);
  25. \draw[->>] (-3,2) -- (3,2);
  26. \draw[->|] (-3,1) -- (3,1);
  27. \draw[-to] (-3,0) -- (3,0);
  28. \draw[-latex] (-3,-1) -- (3,-1);
  29. \draw[-stealth] (-3,-2) -- (3,-2);
  30. \end{tikzpicture}
  31. \begin{tikzpicture}
  32. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  33. \draw[->] (-3,0) -- (3,0);
  34. \draw[->] (0,-3) -- (0,3);
  35. \draw (0,0) circle (1);
  36. \end{tikzpicture}
  37. \begin{tikzpicture}
  38. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  39. \draw[->] (-3,0) -- (3,0);
  40. \draw[->] (0,-3) -- (0,3);
  41. \draw (0,0) ellipse (1 and 0.5);
  42. \end{tikzpicture}
  43. \begin{tikzpicture}
  44. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  45. \draw[->] (-3,0) -- (3,0);
  46. \draw[->] (0,-3) -- (0,3);
  47. \draw[color=gray!40] (0,0) circle (1); %
  48. \draw[color=red] (1,0) arc (0:45:1);
  49. \draw[color=gray!40] (0,0) ellipse (1 and 0.5);
  50. \draw[color=green] (1,0) arc (0:60:1 and 0.5);
  51. \end{tikzpicture}
  52. \begin{tikzpicture}[scale=2]
  53. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  54. \draw[color=red] (-1,-1) rectangle (1,1);
  55. \end{tikzpicture}
  56. hello\\\\\\
  57. \begin{tikzpicture}
  58. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  59. \path (1,1) coordinate (p1);
  60. \coordinate (p2) at ( 2, 0);
  61. \draw[dotted, red] (p1) -- (p2) ;
  62. \end{tikzpicture}
  63. \begin{tikzpicture}[scale=2]
  64. \draw[step=1,color=gray!40] (-2,-2) grid (2,2);
  65. \draw[latex-latex, red] (0,-2) -- ++(-1,1) -- ++(-1,-1);
  66. \draw[dashed, blue] (0,1) -- +(-1,1) -- +(-2,0);
  67. \end{tikzpicture}
  68. \\\\\\\\testtt\\\\\\\\
  69. \begin{tikzpicture}
  70. \node (node001) at (0,2) [draw] {test};
  71. \end{tikzpicture}
  72. \begin{tikzpicture}
  73. \node (node001) at (0,2) [draw] {node001};
  74. \node (node002) at (-2,0) [draw] {node002};
  75. \node (node003) at (2,0) [draw] {node003};
  76. \draw (node cs:name=node003,anchor=north) |- (0,1);
  77. \draw (node002.north) |- (0,1) -| (node cs:name=node001,anchor=south);
  78. \end{tikzpicture}
  79. \\\\good testtt\\\\\\\\
  80. \begin{tikzpicture}
  81. \node (p1) at (30:1) {$p_1$} ;
  82. \node (p2) at (75:1) {$p_2$} ;
  83. \draw (-0.2,0) -- (1.2,0) node[right] (xline) {$q_1$};
  84. \draw (2,-0.2) -- (2,1.2) node[above] (yline) {$q_2$};
  85. \draw[->] (p1) -- (p1 |- xline);
  86. \end{tikzpicture}
  87. \begin{tikzpicture}
  88. \node (p1) at (30:1) {$p_1$} ;
  89. \node (p2) at (75:1) {$p_2$} ;
  90. \draw (-0.2,0) -- (1.2,0) node[right] (xline) {$q_1$};
  91. \draw (2,-0.2) -- (2,1.2) node[above] (yline) {$q_2$};
  92. \draw[->] (p1) -- (p1 |- xline);
  93. \end{tikzpicture}
  94. \\\\hello\\\\
  95. \begin{tikzpicture}
  96. \draw [ultra thick] (0,1) -- (2,1);
  97. \draw [thick] (0,0.5) -- (2,0.5);
  98. \draw [thin] (0,0) -- (2,0);
  99. \end{tikzpicture}
  100. \\\\hello\\\\\\\\
  101. \begin{tikzpicture}
  102. \draw [line width=0.4pt] (0,0) -- (2,0);
  103. \draw[red] (0,1) -- (2,1);
  104. \draw [line width=0.2cm] (4,.75) -- (5,.25);
  105. \end{tikzpicture}
  106. \\\\hello\\\\\\\\
  107. \begin{tikzpicture}[scale=3]
  108. \draw[help lines] (0,0) grid (2,2);
  109. \draw[color=red] (0,0) .. controls (1,1) and (2,1) .. (2,0);
  110. \shade[ball color=gray!10] (0,0) circle (0.1);
  111. \shade[ball color=gray!40] (1,1) circle (0.1);
  112. \shade[ball color=gray!70] (2,1) circle (0.1);
  113. \shade[ball color=gray] (2,0) circle (0.1);
  114. \end{tikzpicture}
  115. \begin{tikzpicture}
  116. \shade[ball color=red] (1,2) circle (1);
  117. \end{tikzpicture}
  118. \\\\hello\\\\\\\\
  119. \begin{tikzpicture}[outline/.style={draw=#1,thick,fill=#1!50},
  120. outline/.default=black]
  121. \node [outline]
  122. at (0,1) {default};
  123. \node [outline=blue] at (0,0) {blue};
  124. \end{tikzpicture}
  125. \\\\hello\\\\\\\\
  126. \usetikzlibrary{positioning}
  127. \tikzset{place/.style={circle,draw=blue!50,fill=blue!20,
  128. thick,inner sep=0pt,minimum size=6mm}}
  129. \tikzset{transition/.style={rectangle,draw=black!50,
  130. fill=black!20,thick,inner sep=0pt,minimum size=4mm}}
  131. \tikzset{every label/.style=red}
  132. \begin{tikzpicture}[bend angle=45]
  133. \node[place] (waiting) {};
  134. \node[place] (critical) [below=of waiting] {};
  135. \node[place](semaphore) [below=of critical,label=above:$s\le3$] {};
  136. \node[transition](leave critical) [right=of critical]{};
  137. \node[transition] (enter critical)[left=of critical]{};
  138. \draw [->] (enter critical) to (critical);
  139. \draw [->] (waiting) to [bend right] (enter critical);
  140. \draw [->] (enter critical) to [bend right] (semaphore);
  141. \draw [->] (semaphore) to [bend right] (leave critical);
  142. \draw [->] (critical) to (leave critical);
  143. \draw [->] (leave critical) to [bend right] (waiting);
  144. \end{tikzpicture}
  145. \\\\hello\\\\\\\\
  146. \begin{tikzpicture}
  147. \draw[help lines] (0,0) grid (3,2);
  148. \foreach \x in {0,1,...,4}
  149. \draw[xshift=\x cm] (0,-1) -- (0,1);
  150. \end{tikzpicture}
  151. \\\\hello\\\\\\\\
  152. \begin{tikzpicture}
  153. \draw[help lines] (0,0) grid (3,2);
  154. \draw (0,0) -- (1,1);
  155. \draw[red] (0,0) -- ([xshift=1cm] 1,1);
  156. \end{tikzpicture}
  157. \\\\hello\\\\\\\\
  158. \begin{tikzpicture}
  159. \draw (0,0)[rotate=30] ellipse (2 and 1);
  160. \end{tikzpicture}
  161. \\\\hello\\\\\\\\
  162. \begin{tikzpicture}
  163. \begin{axis}
  164. \addplot{x*2};
  165. \end{axis}
  166. \end{tikzpicture}
  167. \\\\hello\\\\\\\\
  168. \begin{tikzpicture}
  169. \begin{axis}
  170. \addplot coordinates
  171. {(0,0)
  172. (1,1)
  173. (2,3)
  174. (3,9)};
  175. \end{axis}
  176. \end{tikzpicture}
  177. \\\\hello\\\\\\\\
  178. \\\\hello\\\\\\\\
  179. \\\\hello\\\\\\\\
  180. \\\\hello\\\\\\\\
  181. \\\\hello\\\\\\\\
  182. \\\\hello\\\\\\\\
  183. \\\\hello\\\\\\\\
  184. \\\\hello\\\\\\\\
  185. \\\\hello\\\\\\\\
  186. \end{document}

2,效果示例

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/238074
推荐阅读
相关标签
  

闽ICP备14008679号