当前位置:   article > 正文

Tikz 画图技巧一_tikzpicture和wrapfigure

tikzpicture和wrapfigure

效果图:

 演示代码:

  1. \documentclass{article}
  2. \usepackage{tikz,mathpazo} %图形绘制宏包
  3. \usepackage{float} %浮动包
  4. \usepackage{booktabs} %表格线条粗细控制
  5. \usepackage{graphicx}%插入图片
  6. \begin{document}
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. \begin{figure}[H]
  9. \centering
  10. \begin{tikzpicture}
  11. %坐标轴
  12. \draw[->,ultra thick](0,0)--(10,0) node[above]{\textbf{$t$}};
  13. \draw[->,ultra thick](0,0)--(0,6) node[left]{\textbf{$u$}};
  14. \draw (0,0) node[below=3.6pt]{$0$};
  15. %x轴坐标
  16. \draw (1.5,0) node[below=3.6pt]{$t_{1}$};
  17. \draw (4,0) node[below=3.6pt]{$ t_{n}$};
  18. \draw (6.5,0) node[below=3.6pt]{$t_{n+1}$};
  19. \draw (9,0) node[below=3.6pt]{$T$};
  20. %y轴坐标
  21. \draw (0,0.5) node[left=3.6pt]{$u_{0}$};
  22. \filldraw (0,0.5)circle(0.8ex);%黑点
  23. %数值解的实线
  24. \draw (1.5,0) --(1.5,3) node[left]{$u_{1}$};
  25. \filldraw (1.5,3)circle(0.8ex);
  26. \draw (4,0) --(4,4) node[above=3.6pt]{$u_{n}$};
  27. \filldraw (4,4)circle(0.8ex);
  28. \draw (6.5,0) --(6.5,4.5) node[above]{$u_{n+1}$};
  29. \filldraw (6.5,4.5)circle(0.8ex);
  30. \filldraw (9,4.5)circle(0.8ex);
  31. %数值解的连线
  32. \draw (0,0.5) --(1.5,3);
  33. \draw (1.5,3) --(4,4);
  34. \draw (4,4) --(6.5,4.5);
  35. \draw (6.5,4.5) --(9,4.5)node[above]{};
  36. %解析解的实线
  37. \draw (4,0) --(4,2.8) node[right=3.6pt]{$u(t_{n})$};
  38. \draw (4,2.8)circle(0.8ex);
  39. \draw (6.5,0) --(6.5,3.5) node[below=3.6,right]{$u(t_{n+1})$};
  40. \draw (6.5,3.5)circle(0.8ex);
  41. %解析解的连线
  42. \draw (0,0.5) --(4,2.8);
  43. \draw (4,2.8) --(6.5,3.5);
  44. \draw (6.5,3.5) --(9.5,3.6)node[above]{};
  45. %t1和tn之间的点
  46. \draw (1.5,0)--node[below=5pt]{.............}(4,0);
  47. \draw (6.5,0)--node[below=5pt]{.............}(9,0);
  48. %===============================================
  49. \draw(6.5,-1)--(6.5,-1.5);
  50. \draw(4,-1)--(4,-1.5);
  51. \draw[<->,thick](4,-1.3)--(6.5,-1.3);
  52. \draw (4,-1.3)--node[above]{$h$}(6.5,-1.3);
  53. \end{tikzpicture}
  54. \end{figure}
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. \vspace{1.5cm}
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58. \begin{figure}[H]
  59. \centering
  60. \begin{tikzpicture}
  61. %坐标轴
  62. \draw[->](-0.3,0)--(12,0) node[right]{$x$};
  63. \draw[->](0,-0.3)--(0,7) node[right]{$t$};
  64. %x轴坐标
  65. \draw (2.5,0) node[below=3.6pt]{$x_{j-1}$};
  66. \draw (6.5,0) node[below=3.6pt]{$x_{j}$};
  67. \draw (10.5,0) node[below=3.6pt]{$x_{j+1}$};
  68. \draw (4.208,3.5) node[above=7.2pt,right=0.9pt]{\textbf{P}};
  69. %y轴坐标
  70. \draw (0,3.5) node[left=3.6pt]{$t_{n}$};
  71. \draw (0,6) node[left=3.6pt]{$t_{n+1}$};
  72. %虚线
  73. \draw[-,dashed] (1,0)--(7.5,7.09);
  74. \draw[-,dashed] (11.5,0)--(5.592,7.09);
  75. %实线
  76. \draw [ultra thick] (2.5,0) --(2.5,7.3) ;
  77. \draw [ultra thick](6.5,0) --(6.5,7.3);
  78. \draw [ultra thick](10.5,0) --(10.5,7.3);
  79. \draw[ultra thick](-0.3,6) --(11.5,6);%粗体线条
  80. \draw[ultra thick](-0.3,3.5) --(11.5,3.5);
  81. %黑点
  82. \filldraw (2.5,0)circle(0.4ex);
  83. \filldraw (6.5,0)circle(0.4ex);
  84. \filldraw (10.5,0)circle(0.4ex);
  85. \filldraw (2.5,3.5)circle(0.4ex);
  86. \filldraw (2.5,6)circle(0.4ex);
  87. \filldraw (6.5,3.5)circle(0.4ex);
  88. \filldraw (6.5,6)circle(0.4ex);
  89. \filldraw (10.5,3.5)circle(0.4ex);
  90. \filldraw (10.5,6)circle(0.4ex);
  91. \filldraw (4.208,3.5)circle(0.4ex);%交点P
  92. %交点P左右箭头
  93. \draw[<->,very thick](2.5,3.8)--(4.208,3.8);
  94. \draw (2.5,3.8)--node[above=0.9pt]{$\delta x-c\delta t$ }(4.208,3.8);
  95. \draw[<->,very thick](4.208,3.2)--(6.5,3.2);
  96. \draw (4.208,3.2)--node[below=0.9pt]{$c\delta t$ }(6.5,3.2);
  97. %标注直线方程
  98. \draw (3,2.3)node[right=3.6pt]{$(c>0)$};
  99. \draw (10,2.3)node[left=10.8pt]{$(c<0)$};
  100. \end{tikzpicture}
  101. \end{figure}
  102. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  103. \end{document}

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

闽ICP备14008679号