Tikz 中的倾斜和水平箭头

Tikz 中的倾斜和水平箭头

嘿,大家好,我几乎确信对此有一些非常简单的解决方案,但我不知道该搜索什么/在哪里搜索。

我想要做的可以在下面的图片中看到红线(带或不带箭头,并不重要)。

在此处输入图片描述 你们知道怎么做吗?我开始尝试使用 \coordinate 和 invisible nodes,但失败了。

该代码的代码示例:

\newlength{\spalte}
\setlength{\spalte}{7cm}
\newlength{\double}
\setlength{\double}{0.7cm}

\node (init) [progline] {Download};
\node (preproc) [process, below of = init] {Preprocessing};
\node (shrink) [process, right of=preproc, yshift=\double, node distance=\spalte] {Preprocessing};
\node (clean) [process, right of = preproc, yshift=-\double, node distance=\spalte] {Preprocessing};

% Draw edges
\draw [arrow] (init) -- (preproc);
\draw [arrow] (preproc) -| (shrink);
\draw [arrow] (preproc) -- (clean);

编辑:如果有人来到这一点,我现在的最终解决方案(包括箭头)如下: 在此处输入图片描述

\usepackage{tikz} %Flowchart
\usetikzlibrary{shapes,arrows, positioning} %Flowchart  

% Define block styles
\tikzstyle{treenode} = [shape=rectangle, rounded corners,
draw, anchor=center,
text width=5cm, align=center,
top color=white, bottom color=blue!20,
inner sep=1ex]
\tikzstyle{progline} = [treenode, font=\Large, bottom color=red!30]
\tikzstyle{process} = [treenode, font=\ttfamily\normalsize]
\tikzstyle{invisible} = [inner sep=0,minimum size=0]

\tikzstyle{arrow} = [thick,->,>=stealth]    %Arrow shape
\tikzstyle{arrow_right} = [thick,<-,>=stealth]  %Arrow shape



\pgfmathsetlengthmacro{\double}{0.7cm}

\begin{tikzpicture}[node distance = 1cm, auto]
% Place nodes
\node (init) [progline] {Download};
\node (preproc) [process, below=of init] {Preprocessing};
    \node (shrink) [process, right=of preproc, yshift=\double] {shrinking};

\node (clean) [process, right=of preproc, yshift=-\double] {cleaning};
% Draw edges
\draw [arrow] (init) -- (preproc);
\draw [arrow] (preproc) -| (shrink);
\draw [arrow] (preproc) -- (clean);
\draw [arrow_right] (shrink.west) -- ++(-0.5,0) -- (preproc.east);
\end{tikzpicture}

答案1

如果你能贴出你最初尝试的代码就好了。但是,假设最左边的预处理节点被称为prepro1,并且最顶层prepro2,你可以尝试类似

\draw [red] (prepro2.west) -- ++(-0.5,0) -- (prepro1.east);

是否-0.5合适取决于您的设置,您可能需要增加或减少它。

使用您的代码片段,并添加缺少的样式的简单定义,它可能看起来像下面的代码。一些注意事项:

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[progline/.style={draw,fill=red!30},process/.style={draw,fill=blue!20},arrow/.style={-stealth}]
\pgfmathsetlengthmacro{\spalte}{7cm}
\pgfmathsetlengthmacro{\double}{0.7cm}

\node (init) [progline] {Download};
\node (preproc) [process, below=of init] {Preprocessing};
\node (shrink) [process, right=of preproc, yshift=\double, node distance=\spalte] {Preprocessing};
\node (clean) [process, right=of preproc, yshift=-\double, node distance=\spalte] {Preprocessing};

% Draw edges
\draw [arrow] (init) -- (preproc);
\draw [arrow] (preproc) -| (shrink);
\draw [arrow] (preproc) -- (clean);

% additional line
\draw [red] (shrink.west) -- ++(-0.5,0) -- (preproc.east);
\end{tikzpicture}
\end{document}

相关内容