8

I have an edge from node A to node B:

\draw[] (A) edge (B);

This creates an edge as follows:

A --------------------------------- B

I would like to know what properties I have to fill inside [] such that the edge looks as follows:

A -------- - - -                     B

In other words, the edge should only be visible until the half of the path between A and B (or until some fixed distance would be fine too), and the edge should fade out trough dots.

4

Not exactly fading, but would this be sufficient? Using calc:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
    thick]
    \node (A)  at (0,0)  {A};
    \node (B)  at (5,0) {B};
    \draw[] (A) edge ($(A)!0.45!(B)$) edge [dotted] ($(A)!0.55!(B)$);
\end{tikzpicture}
\end{document}

Result from the code above

basically, it's drawing a plain edge between A and 45% of the path from A to B, and then adds a 10% lenght of dotted path. You can clearly change the numbers (or add more sections, like another one with more spaced dots, or with gray dots, you got the idea).

You can use absolute distances on the line (see section 13.5.4 of the tikz manual, "The Syntax of Distance Modifiers"):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
    thick]
    \node (A)  at (0,0)  {A};
    \node (B)  at (5,3) {B};
    \draw[] (A) edge ($(A)!3cm!(B)$) edge [dotted] ($(A)!3.4cm!(B)$);
\end{tikzpicture}
\end{document}

New output

  • Thank you very much! Do you also know a way to specify it in terms of absolute length? – ndrizza Apr 7 '16 at 15:41
  • @ndrizza Look at the new edit... – Rmano Apr 7 '16 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.