在 LaTeX 中绘图

在 LaTeX 中绘图

我非常喜欢使用 Tikz 在 LaTex 文档中绘制简单小图表。但是,我技术不太好,所以我想找人帮我实现这个绘图(没有颜色:D)。谢谢大家的帮助!

在此处输入图片描述

答案1

由于您是初学者,而且我还有一些时间,因此我将为您提供一个非常基本的图表入门指南。实际上,它很好地复制了图表。您可以尝试使用此指南和 PGF 手册。

希望您将来能在 LaTeX Stack Exchange 中更多地帮助别人。

图片取自我提供的代码

\documentclass[margin=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
 \begin{tikzpicture}[scale=1.3]
  \begin{scope}[fill=teal!20]
   \fill[rounded corners=2mm] (0,0) rectangle (2,2);
   \fill (2,1.25) rectangle (3,1.5)
   (3,1) rectangle (3.75,1.75)
   (3.75,1.75) rectangle (7,0.5);
   \node [shape=isosceles triangle, fill=black,rotate=90,scale=0.3] at (2.5,1.25){};
   \node [shape=isosceles triangle, fill=black,rotate=-90,scale=0.3] at (2.5,1.5){};
  \end{scope}
  \begin{scope}[fill=gray!60]
   \fill [rounded corners=1mm] (3.1,1.1) rectangle (4.1,1.65);
   \fill [rounded corners=1mm] (3.85,1.65) rectangle (7.0,0.6);
   \fill (7,1) rectangle (8,1.25);
  \end{scope}
  \fill [yellow] (8,0.75) rectangle (10,1.5);
  \fill [black]
  (8.4,0.6) circle (0.15)
  (8.7,0.6) circle (0.15)
  (9.3,0.6) circle (0.15)
  (9.6,0.6) circle (0.15);
  \draw[thick] (10,1.2) .. controls (10.25,1.2) and (10.25,2) .. (10.5,2);
  \foreach \y in {0.8,0.9,1.0,1.3,1.4}
   \draw[red,<-] (7,\y) -- (7.5,\y);
  \foreach \y in {1.15, 1.35, 1.55}
   \draw[red,->] (2.75,\y) -- (3.1,\y);
  \draw [red,->] (2.75,0.95) .. controls (3.5,1) and (3,0.7) .. (3.85,0.7);
  \node [align=center,anchor=north] at (1,0) {Serbatoio ad\\aria compressa};
  \node [anchor=north] at (2.75,0) {Valvola};
  \node [align=center,anchor=north] at (5.5,0) {Sistema cilindro - pistone\\con sezione a scalino};
  \node [align=center,anchor=north] at (9,0) {Slitta di\\alaggio};
  \node[red] at (2.75,2) {Pressione};
  \node[red] at (6.75,2) {Contro-Pressione};
  \node [align=center] at (9.75,2) {Cavo di\\traino};
 \end{tikzpicture}
\end{document}

答案2

非常感谢 anakrich!我没有发布任何代码,因为我不知道如何开始 XD 我尝试使用你的代码来获得更时尚的东西 :P 这是修改后的代码:

\begin{tikzpicture}[scale=1]

% Cylinder
\begin{scope}[fill=teal!20]
    \fill[draw, rounded corners=2mm] (0,0) rectangle (2,3);
    \fill (1.9,1.25) rectangle (3,1.5)
    (3,1) rectangle (3.75,1.75)
    (3.75,1.75) rectangle (7,0.5);
    \node [shape=isosceles triangle, fill=black,rotate=90,scale=0.3] at (2.5,1.25){};
    \node [shape=isosceles triangle, fill=black,rotate=-90,scale=0.3] at (2.5,1.5){};
\end{scope}

% Cylinder Boundary 
\draw[thick] (2,1.25) -- (3,1.25);
\draw[thick] (3,1.25) -- (3,1);
\draw[thick] (3,1) -- (3.75,1);
\draw[thick] (3.75,1) -- (3.75,0.5);
\draw[thick] (3.75,0.5) -- (6.98,0.5);
\draw[thick] (6.98,0.5) -- (6.98,0.6);
\draw[thick] (6.98,1.65) -- (6.98,1.75);
\draw[thick] (6.98,1.75) -- (3,1.75);
\draw[thick] (3,1.75) -- (3,1.5);
\draw[thick] (3,1.5) -- (2,1.5);

% Piston
\begin{scope}[fill=gray!60]
    \fill (3.1,1.1) rectangle (4.1,1.65);
    \fill (3.85,1.65) rectangle (7.0,0.6);
    \fill (7,1) rectangle (8,1.25);
\end{scope}

% Piston Boundary   
\draw[thick] (7,1) -- (8, 1);   
\draw[thick] (7,1.25) -- (8, 1.25);
\draw[thick] (3.85,0.6) -- (7, 0.6);
\draw[thick] (7,0.6) -- (7, 1);
\draw[thick] (7,1.25) -- (7, 1.65);
\draw[thick] (3.1,1.65) -- (7, 1.65);
\draw[thick] (3.1,1.65) -- (3.1, 1.1);
\draw[thick] (3.1,1.1) -- (3.85, 1.1);
\draw[thick] (3.85,1.1) -- (3.85, 0.6);

% Sled
\fill [yellow] (8,0.75) rectangle (10,1.5);
\fill [black]
(8.4,0.6) circle (0.15)
(8.7,0.6) circle (0.15)
(9.3,0.6) circle (0.15)
(9.6,0.6) circle (0.15);
\draw[thick] (10,1.2) .. controls (10.25,1.2) and (10.25,2) .. (10.5,2);

% Sled Boundary
\draw[thick] (8,0.75) -- (10,0.75);
\draw[thick] (10,0.75) -- (10, 1.5);
\draw[thick] (8,1.5) -- (10,1.5);
\draw[thick] (8,0.75) -- (8, 1.5);

% Ground
\draw[thick] (8,0.45) -- (10,0.45);
\fill [pattern = north east lines] (8,0.25) rectangle (10,0.45);

% Text
\node [align=center,anchor=north] at (1,0) {Serbatoio ad\\aria compressa};
%\node [anchor=north] at (2.75,0) {Valvola};
\node [align=center,anchor=north] at (5.3,0) {Sistema cilindro - pistone\\con sezione a scalino};
\node [align=center,anchor=north] at (9,0) {Slitta di\\alaggio};
\node[red] at (2.85,2) {Pressione};
\node[red] at (6.75,2) {Contro-Pressione};
\node [align=center] at (9.75,2.5) {Cavo di\\traino};

% Arrows
\foreach \y in {0.7,0.9,1.35,1.55}
\draw[thick, red,<-] (7,\y) -- (7.5,\y);
\foreach \y in {1.15, 1.35, 1.55}
\draw[thick, red,->] (2.75,\y) -- (3.1,\y);
\draw [thick, red,->] (2.75,0.95) .. controls (3.5,1) and (3,0.7) .. (3.85,0.7);
\end{tikzpicture}

再次,谢谢你 !!!

在此处输入图片描述

相关内容