我的第一张 Tikz 图片:定位帮助和建议

我的第一张 Tikz 图片:定位帮助和建议

我想知道如何使这个图像更好,也许使用更“紧凑”的代码。

另外,我想放置标签IMT以更好地适应箭头。是否可以用阴影填充pompa和之间的轴turbina?最后,我希望框之间的箭头在接触框之前结束。

谢谢你,抱歉我的英语不好。

这是我的代码:

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,intersections,shapes.geometric,fit,arrows,decorations.pathmorphing,decorations.pathreplacing,decorations.shapes,decorations.markings}


\begin{document}

\begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and 3cm]

%set styles for the axis between turbine and pump and for the boxes

\tikzset{asse/.style   = {thick, double,double distance = 6pt}}
\tikzset{box1/.style={draw,minimum width=2.5cm,rectangle,thick}}

% draw nodes

\node[box1] (setA) {\textit{SET A}};
\node[box1] (evaporatore) [below=of setA] {\textit{Evaporatore}};
\node[draw,trapezium,shape border rotate=90,inner sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium angle=80] (turbina) [on grid,below right= of evaporatore] {\textit{Turbina}};
\node[box1] (sem) [right=of turbina] {\textit{SEM}};
\node[box1] (condensatore) [on grid,below left=of turbina] {\textit{Condensatore}};
\node[draw,circle] (pompa) [on grid,below left= of evaporatore] {\textit{Pompa}};
\node[box1] (setB) [below=of condensatore] {\textit{SET B}};

%draw axis between turbine and pump

\node (imt) [draw, dashed,inner sep=3pt, rectangle, fit = (evaporatore) (turbina) (condensatore)(pompa)] {};


%connecting evaporatore-turbina-condensatore-pompa (with arrows in the middle of the path)
\begin{scope}[>=triangle 60]
 \draw [decoration={markings, mark=at position 0.6 with {\arrow{>}}},postaction={decorate}] (evaporatore) -| (turbina.top right corner);
 \draw [decoration={markings, mark=at position 0.6 with {\arrow{>}}},postaction={decorate}]  (turbina.bottom left corner) |- (condensatore);
 \draw [decoration={markings, mark=at position 0.4 with {\arrow{>}}},postaction={decorate}] (condensatore) -| (pompa);
 \draw [decoration={markings, mark=at position 0.6 with {\arrow{>}}},postaction={decorate}] (pompa) |- (evaporatore);
 \end{scope}


%draw the IMT label

\node[] (labelimt) [above right=0.5cm and 0.5cm of imt] {\textit{IMT}};
\draw[->,decorate,decoration={bent,amplitude=-2,aspect=0.3}] (labelimt) -- (imt);

%draw the "asse"

 \draw[asse](pompa) to node[]{asse} (turbina);

 %draw arrows

 \begin{scope}[>=stealth']
 \path[->] (setA) edge node[] {$q_A$} (evaporatore);
 \path[->] (turbina) edge node[] {$l$} (sem);
 \path[->] (condensatore) edge node[] {$q_B$} (setB);
\end{scope}

\end{tikzpicture}
\end{document}

答案1

代替 \draw[asse](pompa) to node[]{asse} (turbina);

\path(pompa) to node[]{asse} (turbina);
\draw[pattern=north east lines] ($(pompa.east)+(0,-3pt)$) rectangle ($(turbina.west)+(0,3pt)$);

\node[] (labelimt) at ([shift={(2,2)}]imt.north east) {\textit{IMT}};
\draw[->,decorate,decoration={bent,amplitude=-2,aspect=0.3}] (labelimt) -- (imt.north east);

去买一支新箭,但我不确定你是否想要

以及shorten >=0.1cm箭头。我添加了新样式:deco并重新格式化代码

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,
               intersections,
               shapes.geometric,
               decorations.pathmorphing,
               decorations.pathreplacing,
               decorations.shapes,
               decorations.markings,
               patterns,
               calc,
               fit,
               arrows, }

\begin{document}

\begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and 3cm]

%set styles for the axis between turbine and pump and for the boxes

\tikzset{box1/.style={draw,minimum width=2.5cm,rectangle,thick}}
\tikzset{deco/.style={decoration={markings,
                       mark=at position #1 with {\arrow{>}}},
                       postaction={decorate}}}
\tikzset{turb/.style={draw,trapezium,shape border rotate=90,inner sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium angle=80,on grid,below right= of evaporatore}}                       
% draw nodes

\node[box1] (setA)                       {\textit{SET A}};
\node[box1,below=of setA] (evaporatore)  {\textit{Evaporatore}};
\node[turb] (turbina)                    {\textit{Turbina}};
\node[box1,right=of turbina] (sem)                            {\textit{SEM}};
\node[box1,on grid,below left=of turbina] (condensatore)      {\textit{Condensatore}};
\node[draw,circle,on grid,below left= of evaporatore] (pompa) {\textit{Pompa}};
\node[box1] (setB)         [below=of condensatore]            {\textit{SET B}};

%draw axis between turbine and pump

\node (imt) [draw, 
             dashed,
             inner sep=3pt,
             fit = (evaporatore) (turbina) (condensatore)(pompa)] {};

%connecting evaporatore-turbina-condensatore-pompa (with arrows in the middle of the path)
\begin{scope}[>=triangle 60]
 \draw [deco=0.6]  (evaporatore)                -| (turbina.top right corner);
 \draw [deco=0.6]  (turbina.bottom left corner) |- (condensatore);
 \draw [deco=0.4]  (condensatore)               -| (pompa);
 \draw [deco=0.6]  (pompa)                      |- (evaporatore);
 \end{scope}

%draw the IMT label

\node[] (labelimt) at ([shift={(2,2)}]imt.north east) {\textit{IMT}};
\draw[->,decorate,decoration={bent,amplitude=-2,aspect=0.3}] (labelimt) -- (imt.north east);

%draw the "asse"

\path(pompa) to node[]{asse} (turbina);
\draw[pattern=north east lines] ($(pompa.east)+(0,-3pt)$) rectangle ($(turbina.west)+(0,3pt)$);
 %draw arrows

 \begin{scope}[>=stealth']
 \path[shorten >=0.1cm,->] (setA) edge node[]         {$q_A$} (evaporatore);
 \path[shorten >=0.1cm,->] (turbina) edge node[]      {$l$}   (sem);
 \path[shorten >=0.1cm,->] (condensatore) edge node[] {$q_B$} (setB);
\end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

干得好。我根据自己的需求对您的代码进行了一些修改,这就是我得到的结果。我只是想知道是否有更好的方法将标签 (1,2,3,4) 放在连接线的箭头标记上。

在此处输入图片描述

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,
                intersections,
                shapes.geometric,
                decorations.pathmorphing,
                decorations.pathreplacing,
                decorations.shapes,
                decorations.markings,
                patterns,
                calc,
                fit,
                arrows,
                backgrounds}
\usepackage{bm}
\begin{document}


\begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and 3cm]

%setting styles

\tikzset{box1/.style={draw,minimum width=2cm,rectangle,thick}}
\tikzset{deco/.style={decoration={markings, mark=at position #1 with {\arrow{>} }},postaction={decorate}}}
\tikzset{turb/.style={draw,trapezium,shape border rotate=90,inner sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium angle=80,on grid,below right= of evaporatore}}                       
\tikzset{every pin edge/.style={<-,shorten >=-0.2cm,decorate,decoration={bent,amplitude=-2,aspect=0.3}}}

%define nodes and labels
\node[box1] (setA)   [label=right:$T_A$]                                               {\textit{SET A}};
\node[box1,below=1cm of setA] (evaporatore)                                            {\textit{Evaporatore}};
\node[turb,fill=white] (turbina)                                                       {\textit{Turbina}};
\node[box1,right=1cm of turbina] (sem)                                                 {\textit{SEM}};
\node[box1,on grid,below left=of turbina] (condensatore)                               {\textit{Condensatore}};
\node[draw,circle,fill=white,on grid,below left= of evaporatore,inner sep=1mm] (pompa) {\textit{Pompa}};
\node[box1] (setB)  [below=1 cm of condensatore] [label=right:$T_B$]                   {\textit{SET B}};

%the "IMT" dashed box and label
\node (imt) [draw,dashed,inner sep=3pt,fit = (evaporatore) (turbina) (condensatore)(pompa),pin={[pin distance=10mm] 30:\textit{IMT}}]  {};


%drawing connections between components
\begin{scope}[>=triangle 60]
 \draw [deco=0.6]  (evaporatore)                -| node[pos=0.6]{2} (turbina.top right corner);
 \draw [deco=0.6]  (turbina.bottom left corner) |- node[above=1mm,pos=0.71]{3} (condensatore);
 \draw [deco=0.4]  (condensatore)               -| node[above=1mm,pos=0.31]{4} (pompa);
 \draw [deco=0.6]  (pompa)                      |- node[below=1mm,pos=0.63]{1} (evaporatore);
\end{scope}

%drawing the arrows

\begin{scope}[>=stealth', shorten >=-0.0cm,shorten <=-0.0cm,->]
 \path[thick] (setA)         edge node[] {$\bm{q_A}$} (evaporatore)
                  (turbina)      edge node[] {$\bm{l}$}   (sem)
                  (condensatore) edge node[] {$\bm{q_B}$} (setB);
\end{scope}

% drawing the shaded axis between "pompa" and "turbina"

\begin{scope}[on background layer]
\draw[shading=axis] ($(pompa.center)+(0,-3pt)$) rectangle ($(turbina.center)+(0,3pt)$);
\end{scope}

\end{tikzpicture}
\end{document}

相关内容