How can I create half arrows like the colored ones in the answer to
this post using TikZ? I know how I can create custom arrow tips, but how can I extend this to the tail of the arrow? I would appreciate some ideas. Thanks.
EDIT: The arrow should sit on top of an undirected edge.
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}
\tikzset{arr/.style={line width=4pt, {-Latex[left]}, #1}}
\begin{document}
\begin{tikzpicture}
\node[draw,circle] (A) at (0,0) {};
\node[draw,circle] (B) at (3,0) {};
\draw (A) to (B);
\draw[arr=green!30] (A) -- (B);
\end{tikzpicture}
\end{document}
produces
which covers the edge underneath. I would also like to have a boundary in a slightly darker green around the arrow except where it touches the edge or a vertex and the tail of the arrow should fit along the start node. It would be nice if the solution would also support bended arrows.
EDIT:
I got a little further with my problem. I used markings to define coordinates near the head and tail of the arrow, which I then connected.
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,arrows,arrows.meta,bending,decorations.pathreplacing,
decorations.pathmorphing,decorations.markings,fit,patterns,
shapes,intersections,calc}
\begin{document}
\tikzset
{
down oriented arrow/.style = {
thick,
decoration={
markings,
mark=at position 0.01 with
{
\coordinate (A) at (0,0);
\coordinate (B) at (.125,.125);
},
mark=at position 0.99 with
{
\coordinate (C) at (-.25,.125);
\coordinate (D) at (-.25,.25);
\coordinate (E) at (0,0);
\filldraw[thick,draw=#1,fill=green!30]
(A) -- (B) -- (C) -- (D) -- (E) -- cycle;
}
},
preaction = {decorate}
},
down oriented arrow/.default=black
}
\begin{tikzpicture}[align=center,node distance=3cm]
\node[draw,circle] (a) {};
\node[draw,circle,right of=a] (b) {};
\node[draw,circle,below of=a] (c) {};
\node[draw,circle,right of=c] (d) {};
\draw[down oriented arrow=green!90] (a) to (b);
\draw[down oriented arrow] (c) to (b);
\draw[down oriented arrow] (d) to[bend right] (b);
\end{tikzpicture}
\end{document}
which gives the following result.
How can I pass the fill color as a second argument to the down oriented arrow
style?
Obviously this does not work for the bended arrow. Any suggestions?
Also I could not fit the tail of the arrow to the node, but I made a compromise there which looks quite ok.
Best Answer
One way, with the
arrows.meta
library ofpgf
/TikZ v3.0.See Section 16.5 of the
pgf
manual for a full listing of available arrow tips and options.The question only requested half-arrows, but Gonzalo Medina provided some additional code in a comment that might be useful in drawing diagrams similar to those in the linked answer:
The style
arr
can be used throughout the diagram(s) with the color provided as an argument. This gives consistency throughout the document, and if you decide to change the drawing style later, it only needs to be updated in one place.