1

I was wondering if there is an easy way to create diagrams like the following: enter image description here

where a, b, c are colors and strings connect like colors. In the paper I am reading, they don't allow crossings, but I would like to allow crossings between different colors. So something like this would be allowed (two colors red and blue)

enter image description here

I tried to do this with the braid package, but the problem is that I don't know how to make those semi-circles

Thanks in advance!

4
  • Do you want any special effect at the crossings, such as a cut-out of the lower strand? Do you want to be able to have strands going over then under so that there isn't a strict drawing order? May 4, 2023 at 5:57
  • It should be possible to construct a (non unique) polynomial in x and y which crosses zero at specific locations. Then draw a contour plots for just one level (page 154 of pgfplots), May 4, 2023 at 12:14
  • @Andrew Stacey, indeed there is no strict drawing order. That would be nice! Thank you.
    – Infimum
    May 4, 2023 at 17:07
  • @John Kormylo Thanks! I'll have to check it out!
    – Infimum
    May 4, 2023 at 17:08

1 Answer 1

2

Like this:

enter image description here

Code:

\documentclass[a4paper]{article}
\usepackage{tikz}

\begin{document}
    \thispagestyle{empty}
    \begin{tikzpicture}[scale=.7]
        \draw[gray!20] (-5,-5) grid (5,5); % <-- comment this line after seeiing the code
        \draw[red,line width=2pt] (-4,-4)--(-4,4);
        \draw[blue,line width=2pt] (-3,-4)--(-3,4);
        \draw[blue,line width=2] (4,-4) arc (0:180:3);
        \draw[blue,line width=2] (4,4) arc (0:-180:3);
        \draw[red,line width=2pt] (.5,-4)--(.5,4);
        \draw[red,line width=2pt] (1.5,-4)--(1.5,4);
    \end{tikzpicture}   
\end{document}

EDIT: If You want colored dots at the end of each line-arc add this line before \end{tikzpicture} :

\foreach \j in {-4,4}{
            \foreach \i/\c in {-4/red,-3/blue,-2/blue,.5/red,1.5/red,4/blue} 
            \filldraw[\c] (\i,\j) circle(4pt);
        }

New output:

enter image description here

3
  • Interesting! Is it possible to create slanted "through" strings like the first bottom a connecting to the last top a in the first picture? Thanks! This is a great start!
    – Infimum
    May 4, 2023 at 17:10
  • 1
    Circles may take up some space. Choosing three points would be a simpler option or choosing a cubic Bézier curve.
    – CroCo
    May 4, 2023 at 19:12
  • If I understand the Infimum comment, add this line of code before \end{tikzpicture} (dashed is an option, the cyan color also!): \draw[cyan,line width=2pt,dashed] (-4,-4)--(4,4); May 4, 2023 at 22:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .