I am trying to make a figure like this with tikz:
So I did this:
This gives this picture:
I had meant for the arrows go through the ‘dots’ used to denote the merging and splitting of arrow. Without there being a break.
Also, I wanted the labels and a
, b
, etc above some of the arrows.
Along with the arrow head being in the middle of the arrow instead of being at the end.
Any tips as to how this may be achieved?
Thanks.
This really feels very close to a circuit – and I’m sure circuitikz
has a way to provide a rectangular shape with multiple inputs and outputs without having to misuse a built-in element – but in case you want a plain-ish TikZ solution, I’ll add one with my tools, i.e. the ones from my tikz-ext
package – so much for plain.
Here, I’m using ext.paths.ortho
and its ext/horizontal vertical horizontal
key for the -|-
path operation and ext.arrows-plus
for adding arrow tips along path operation. Since you don’t have any curved lines the ext/arrow
pic is enough.
For a rectangle with multiple, evenly spaced inputs and output anchors, I’m using a slight alteration to the \pgfDeclareGenericAnchorsLinear
macro from an answer on the other site. There’s also a similar, less automatic version available.
Basically, with
xxxxxxxxxx
define linear anchors={north west}{south west}{3}{west}{funcHalfPadding}
three generic anchors
west 1/3
,west 2/3
andwest 3/3
are defined that are placed according to the PGFMath function funcHalfPadding
between a shape’s north west
and south east
anchors.
Generic means that these are always available for every node and every shape (at least in the scope where this key/macro is used – which is the whole document in this case).
Both the Triangle
arrow tip as well as the Circle
are placed as arrow tips, the default settings makes it so that they are centered-ish along the line and not placed with their tip at the center which visually looks too offset. Technically, you don’t need to use arrow tips here, you could just place a node, say node[circle, fill]{}
for the circle, or a custom pic along a path. Unfortunately, the manual’s example is a seagull which isn’t very inspiring.
You could just draw your triangle yourself:
xxxxxxxxxx
\tikzset{
triangle/.pic={
\draw[pic actions] (-5mm,-5mm) -- (5mm,0pt) -- (-5mm,5mm) -- cycle;}}
and wouldn’t be constrained to the available arrow tips.
There can also be made an argument for the circle to be a node that is used to connect if it is a vertex in the graph sense and not just a annotation to the connection like the triangles. (This solution also draws the parts of the connections and some annotations twice or thrice which can be avoided by using the circular node as a vertex.)
If you find yourself, often needing to use these arrow tips on the -|-
paths then you might want to define every
xxxxxxxxxx
\tikzset{
->->-/.style={->-=very near start, ->-=very near end},
->---/.style={->-=very near start},
--->-/.style={->-=very near end},
-o--/.style={-o-=near start},
--o-/.style={-o-=near end}
}
for all variations of these connections.