6

I have a somewhat complex figure in tikz.

enter image description here

You'll notice there are two colors (they look red and green to me, but I'm told they are distinguishable to color-blind people: if you're color blind and they aren't different, please tell me). I would like to draw an appropriately-shapped node that encloses all of the circles that contain two red and two green with the central node red, and another that encloses all the circles with two red and two green and the central node is green. I want these nodes to not intersect or contain any other nodes.

Here is the code I've used to create my figure.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, backgrounds, fit, arrows, arrows.meta}
\definecolor{colorS}{RGB}{0,154,128}
\definecolor{colorI}{RGB}{255,32,0}
\tikzstyle{SusCirc}=[circle,draw=black!50,fill=colorS!90,thick, minimum size=2mm, inner sep = 0mm]%a circle
                                %representing a susceptible individual
\tikzstyle{InfCirc}=[circle,draw=black!50,fill=colorI!90,thick, minimum size=2mm, inner sep = 0mm]%a circle
                                %representing an infected individual
\tikzstyle{BigCirc}=[circle,draw=black!50,thick,inner sep=0pt,minimum size=0pt, inner sep = 0mm]



\begin{document}
\begin{tikzpicture}
\coordinate (top) at (0.000000,0.2500000);
\coordinate (left) at (-0.2165,-0.1250000);
\coordinate (right) at (0.2165,-0.1250000);
\coordinate (center) at (0,0);

\coordinate (SSSSloc) at (10.000000, 0.000000);
  \node[SusCirc, minimum size = 2mm] (SSSScenter) at ($(SSSSloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (SSSSleft) at ($(SSSSloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (SSSStop) at ($(SSSSloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (SSSSright) at ($(SSSSloc)+(right)$) {};
  \draw [-] (SSSScenter) -- (SSSSleft);
  \draw [-] (SSSScenter) -- (SSSStop);
  \draw [-] (SSSScenter) -- (SSSSright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SSSScenter)(SSSSleft)(SSSStop)(SSSSright)] (SSSS) at (SSSSloc) {};
\end{pgfonlayer}


\coordinate (SSSIloc) at (8.349598, 2.05150);
  \node[SusCirc, minimum size = 2mm] (SSSIcenter) at ($(SSSIloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (SSSIleft) at ($(SSSIloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (SSSItop) at ($(SSSIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (SSSIright) at ($(SSSIloc)+(right)$) {};
  \draw [-] (SSSIcenter) -- (SSSIleft);
  \draw [-] (SSSIcenter) -- (SSSItop);
  \draw [-] (SSSIcenter) -- (SSSIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SSSIcenter)(SSSIleft)(SSSItop)(SSSIright)] (SSSI) at (SSSIloc) {};
\end{pgfonlayer}


\coordinate (SSISloc) at (7.109723, 1.3464);%+0.2
  \node[SusCirc, minimum size = 2mm] (SSIScenter) at ($(SSISloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (SSISleft) at ($(SSISloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (SSIStop) at ($(SSISloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (SSISright) at ($(SSISloc)+(right)$) {};
  \draw [-] (SSIScenter) -- (SSISleft);
  \draw [-] (SSIScenter) -- (SSIStop);
  \draw [-] (SSIScenter) -- (SSISright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SSIScenter)(SSISleft)(SSIStop)(SSISright)] (SSIS) at (SSISloc) {};
\end{pgfonlayer}


\coordinate (SSIIloc) at (4.911270, 2.8868);
  \node[SusCirc, minimum size = 2mm] (SSIIcenter) at ($(SSIIloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (SSIIleft) at ($(SSIIloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (SSIItop) at ($(SSIIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (SSIIright) at ($(SSIIloc)+(right)$) {};
  \draw [-] (SSIIcenter) -- (SSIIleft);
  \draw [-] (SSIIcenter) -- (SSIItop);
  \draw [-] (SSIIcenter) -- (SSIIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SSIIcenter)(SSIIleft)(SSIItop)(SSIIright)] (SSII) at (SSIIloc) {};
\end{pgfonlayer}


\coordinate (SISSloc) at (7.059278, -1.007567); %-0.2
  \node[SusCirc, minimum size = 2mm] (SISScenter) at ($(SISSloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (SISSleft) at ($(SISSloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (SISStop) at ($(SISSloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (SISSright) at ($(SISSloc)+(right)$) {};
  \draw [-] (SISScenter) -- (SISSleft);
  \draw [-] (SISScenter) -- (SISStop);
  \draw [-] (SISScenter) -- (SISSright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SISScenter)(SISSleft)(SISStop)(SISSright)] (SISS) at (SISSloc) {};
\end{pgfonlayer}


\coordinate (SISIloc) at (4.955251, 1.31373); 
  \node[SusCirc, minimum size = 2mm] (SISIcenter) at ($(SISIloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (SISIleft) at ($(SISIloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (SISItop) at ($(SISIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (SISIright) at ($(SISIloc)+(right)$) {};
  \draw [-] (SISIcenter) -- (SISIleft);
  \draw [-] (SISIcenter) -- (SISItop);
  \draw [-] (SISIcenter) -- (SISIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SISIcenter)(SISIleft)(SISItop)(SISIright)] (SISI) at (SISIloc) {};
\end{pgfonlayer}


\coordinate (SIISloc) at  (3.473197, 0.17413);
  \node[SusCirc, minimum size = 2mm] (SIIScenter) at ($(SIISloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (SIISleft) at ($(SIISloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (SIIStop) at ($(SIISloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (SIISright) at ($(SIISloc)+(right)$) {};
  \draw [-] (SIIScenter) -- (SIISleft);
  \draw [-] (SIIScenter) -- (SIIStop);
  \draw [-] (SIIScenter) -- (SIISright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SIIScenter)(SIISleft)(SIIStop)(SIISright)] (SIIS) at (SIISloc) {};
\end{pgfonlayer}


\coordinate (SIIIloc) at (1.487967, 2.03170);
  \node[SusCirc, minimum size = 2mm] (SIIIcenter) at ($(SIIIloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (SIIIleft) at ($(SIIIloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (SIIItop) at ($(SIIIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (SIIIright) at ($(SIIIloc)+(right)$) {};
  \draw [-] (SIIIcenter) -- (SIIIleft);
  \draw [-] (SIIIcenter) -- (SIIItop);
  \draw [-] (SIIIcenter) -- (SIIIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (SIIIcenter)(SIIIleft)(SIIItop)(SIIIright)] (SIII) at (SIIIloc) {};
\end{pgfonlayer}


\coordinate (ISSSloc) at (8.323451, -1.79198);
  \node[InfCirc, minimum size = 2mm] (ISSScenter) at ($(ISSSloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (ISSSleft) at ($(ISSSloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (ISSStop) at ($(ISSSloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (ISSSright) at ($(ISSSloc)+(right)$) {};
  \draw [-] (ISSScenter) -- (ISSSleft);
  \draw [-] (ISSScenter) -- (ISSStop);
  \draw [-] (ISSScenter) -- (ISSSright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (ISSScenter)(ISSSleft)(ISSStop)(ISSSright)] (ISSS) at (ISSSloc) {};
\end{pgfonlayer}


\coordinate (ISSIloc) at (6.478631, 0.190366);
  \node[InfCirc, minimum size = 2mm] (ISSIcenter) at ($(ISSIloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (ISSIleft) at ($(ISSIloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (ISSItop) at ($(ISSIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (ISSIright) at ($(ISSIloc)+(right)$) {};
  \draw [-] (ISSIcenter) -- (ISSIleft);
  \draw [-] (ISSIcenter) -- (ISSItop);
  \draw [-] (ISSIcenter) -- (ISSIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (ISSIcenter)(ISSIleft)(ISSItop)(ISSIright)] (ISSI) at (ISSIloc) {};
\end{pgfonlayer}


\coordinate (ISISloc) at (5.037411, -0.94354);
  \node[InfCirc, minimum size = 2mm] (ISIScenter) at ($(ISISloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (ISISleft) at ($(ISISloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (ISIStop) at ($(ISISloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (ISISright) at ($(ISISloc)+(right)$) {};
  \draw [-] (ISIScenter) -- (ISISleft);
  \draw [-] (ISIScenter) -- (ISIStop);
  \draw [-] (ISIScenter) -- (ISISright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (ISIScenter)(ISISleft)(ISIStop)(ISISright)] (ISIS) at (ISISloc) {};
\end{pgfonlayer}


\coordinate (ISIIloc) at  (2.797099, 1.3294); %+0.2
  \node[InfCirc, minimum size = 2mm] (ISIIcenter) at ($(ISIIloc)+(center)$) {};
  \node[SusCirc, minimum size = 2mm] (ISIIleft) at ($(ISIIloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (ISIItop) at ($(ISIIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (ISIIright) at ($(ISIIloc)+(right)$) {};
  \draw [-] (ISIIcenter) -- (ISIIleft);
  \draw [-] (ISIIcenter) -- (ISIItop);
  \draw [-] (ISIIcenter) -- (ISIIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (ISIIcenter)(ISIIleft)(ISIItop)(ISIIright)] (ISII) at (ISIIloc) {};
\end{pgfonlayer}


\coordinate (IISSloc) at (5.071966, -2.5883046);
  \node[InfCirc, minimum size = 2mm] (IISScenter) at ($(IISSloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (IISSleft) at ($(IISSloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (IISStop) at ($(IISSloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (IISSright) at ($(IISSloc)+(right)$) {};
  \draw [-] (IISScenter) -- (IISSleft);
  \draw [-] (IISScenter) -- (IISStop);
  \draw [-] (IISScenter) -- (IISSright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (IISScenter)(IISSleft)(IISStop)(IISSright)] (IISS) at (IISSloc) {};
\end{pgfonlayer}


\coordinate (IISIloc) at (2.951006, -1.02703);%-0.2
  \node[InfCirc, minimum size = 2mm] (IISIcenter) at ($(IISIloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (IISIleft) at ($(IISIloc)+(left)$) {};
  \node[SusCirc, minimum size = 2mm] (IISItop) at ($(IISIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (IISIright) at ($(IISIloc)+(right)$) {};
  \draw [-] (IISIcenter) -- (IISIleft);
  \draw [-] (IISIcenter) -- (IISItop);
  \draw [-] (IISIcenter) -- (IISIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (IISIcenter)(IISIleft)(IISItop)(IISIright)] (IISI) at (IISIloc) {};
\end{pgfonlayer}


\coordinate (IIISloc) at (1.725861, -1.81121);
  \node[InfCirc, minimum size = 2mm] (IIIScenter) at ($(IIISloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (IIISleft) at ($(IIISloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (IIIStop) at ($(IIISloc)+(top)$) {};
  \node[SusCirc, minimum size = 2mm] (IIISright) at ($(IIISloc)+(right)$) {};
  \draw [-] (IIIScenter) -- (IIISleft);
  \draw [-] (IIIScenter) -- (IIIStop);
  \draw [-] (IIIScenter) -- (IIISright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (IIIScenter)(IIISleft)(IIIStop)(IIISright)] (IIIS) at (IIISloc) {};
\end{pgfonlayer}


\coordinate (IIIIloc) at (0.000000, 0.000000);
  \node[InfCirc, minimum size = 2mm] (IIIIcenter) at ($(IIIIloc)+(center)$) {};
  \node[InfCirc, minimum size = 2mm] (IIIIleft) at ($(IIIIloc)+(left)$) {};
  \node[InfCirc, minimum size = 2mm] (IIIItop) at ($(IIIIloc)+(top)$) {};
  \node[InfCirc, minimum size = 2mm] (IIIIright) at ($(IIIIloc)+(right)$) {};
  \draw [-] (IIIIcenter) -- (IIIIleft);
  \draw [-] (IIIIcenter) -- (IIIItop);
  \draw [-] (IIIIcenter) -- (IIIIright);
\begin{pgfonlayer}{background}
  \node[BigCirc, fit = (IIIIcenter)(IIIIleft)(IIIItop)(IIIIright)] (IIII) at (IIIIloc) {};
\end{pgfonlayer}

  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSSS) -- (ISSS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSSS) -- (SSSI);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSSS) -- (SSIS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSSS) -- (SISS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SSSI.240) -- (ISSI.30);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSSI) -- (SSII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSSI) -- (SISI);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SSIS.210) -- (ISIS.70);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSIS) -- (SSII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSIS) -- (SIIS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SSII) -- (ISII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SSII) -- (SIII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SISS) -- (IISS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SISS.150) -- (SISI.290);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SISS) -- (SIIS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SISI.250) -- (IISI.30);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SISI) -- (SIII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SIIS.200) -- (IIIS.70);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-] (SIIS.160) -- (SIII.290);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (SIII) -- (IIII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISSS.110) -- (ISSI.330);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISSS) -- (ISIS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISSS) -- (IISS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISSI) -- (ISII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISSI) -- (IISI);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISIS.110) -- (ISII.330);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISIS) -- (IIIS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (ISII) -- (IIII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (IISS) -- (IISI);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (IISS) -- (IIIS);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (IISI) -- (IIII);
  \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (IIIS) -- (IIII);
\end{tikzpicture}
\end{document}

Is it doable to draw such a node? Ideally I'd like to be able to fill it with another color and I'd like it to not require a lot of fiddling.

Comment on why i'm doing this. I have the initial figure. I'm then showing that these states that I'm joining are symmetric (will also do this to the 3 and 1 nodes), and then I'm switching the edges from being between the original nodes to go between the new partitions. Finally I'm collapsing the partitions into single nodes.

10

Here is a suggestion that involves a complete rewrite of your code. Some more explanation might be added later, but for now, some key points:

  • The states are drawn with a pic instead of a new collection of nodes.

  • The positioning has been adjusted so that things are symmetric (seemed like a thing to do)

  • The arrows are drawn in two \foreach loops.

As for the part that your question is actually about, the code relating to that is the following, found in the end of the tikzpicture:

\begin{scope}[on background layer]
\draw [line width=40pt,opacity=0.3,red,line cap=round,rounded corners] (IISScirc.center) -- (SIIScirc.center) -- (ISIScirc.center);
\draw [line width=40pt,opacity=0.3,blue,line cap=round,rounded corners] (SSIIcirc.center) -- (ISSIcirc.center) -- (SISIcirc.center);

\coordinate (A) at ($(ISSIcirc)!0.4!(SSIIcirc)$);
\coordinate (B) at ($(IISScirc)!0.6!(SIIScirc)$);
\draw [stealth-stealth,ultra thick,green]  ($(A)!20pt!90:(SSIIcirc)$) -- ($(B)!20pt!90:(IISScirc)$);
\end{scope}

The first two lines simply draw a very wide line through the three points specified. The last bit shows one way of calculating points along the edge of this wide line. Likely there are other, and quite possibly better, ways of doing this, but I'm not a wizard either.

Anyway, the first thing that happens is that two coordinates are defined somewhere between two of the nodes. In the first one, A is placed 40% along the way between ISSIcirc and SSIIcirc.

The coordinates used in the \draw statement calculates a projection onto this point, at the specified distance. So ($(A)!20pt!90:(SSIIcirc)$) means the point that is 20pt away from A, along a line that is 90 degrees off from the line between A and SSIIcirc. Why 20pt? Because the line width of the thick line is 40pt, so half that gets you to the edge of that.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, backgrounds, fit, arrows, arrows.meta}

\definecolor{colorS}{RGB}{0,154,128}
\definecolor{colorI}{RGB}{255,32,0}
\tikzset{
S/.style={circle,draw=black!50,fill=colorS!90,thick, minimum size=2mm, inner sep = 0mm},
I/.style={circle,draw=black!50,fill=colorI!90,thick, minimum size=2mm, inner sep = 0mm},
BigCirc/.style={circle,draw=black!50,thick,inner sep=0pt,minimum size=0pt, inner sep = 0mm},
pics/circles/.style args={#1#2#3#4}{
  code={
   \node [#1,minimum size=2mm] (#1#2#3#4top) at (0,0.25) {};
   \node [#2,minimum size=2mm] (#1#2#3#4left) at (-0.2165,-0.125) {};
   \node [#3,minimum size=2mm] (#1#2#3#4right) at (0.2165,-0.125) {};
   \node [#4,minimum size=2mm] (#1#2#3#4center) at (0,0) {};
   \draw (#1#2#3#4top) -- (#1#2#3#4center) -- (#1#2#3#4left) (#1#2#3#4center) -- (#1#2#3#4right);
    \node[BigCirc, fit = (#1#2#3#4left)(#1#2#3#4top)(#1#2#3#4right)] (circ) at (#1#2#3#4center) {};
   }
  }
}

\pgfmathsetmacro{\xA}{1.5}
\pgfmathsetmacro{\xB}{3}
\pgfmathsetmacro{\xC}{3.35}
\pgfmathsetmacro{\yA}{1.2}
\pgfmathsetmacro{\yB}{2.05}
\pgfmathsetmacro{\yC}{2.9}

\begin{document}


\begin{tikzpicture}
\pic (IIII) at (0,0)         {circles=IIII};
\pic (IIIS) at (\xA,\yB)     {circles=IIIS};
\pic (IISI) at (\xA,-\yB)    {circles=IISI};
\pic (ISII) at (\xB,\yA)     {circles=ISII};
\pic (SIII) at (\xB,-\yA)    {circles=SIII};
\pic (IISS) at (\xC,0)       {circles=IISS};
\pic (SIIS) at (5,\yA)       {circles=SIIS};
\pic (ISSI) at (5,-\yA)      {circles=ISSI};
\pic (ISIS) at (5,\yC)       {circles=ISIS};
\pic (SISI) at (5,-\yC)      {circles=SISI};
\pic (SSIS) at (10-\xA,\yB)  {circles=SSIS};
\pic (SSSI) at (10-\xA,-\yB) {circles=SSSI};
\pic (ISSS) at (10-\xB,\yA)  {circles=ISSS};
\pic (SISS) at (10-\xB,-\yA) {circles=SISS};
\pic (SSII) at (10-\xC,0)    {circles=SSII};
\pic (SSSS) at (10,0)        {circles=SSSS};

\foreach \A/\B in {
  IIIS/SIIS, IIIS/ISIS, IIIS/IISS, IISS/ISSS,
  IISS/SISS, ISIS/ISSS, ISIS/SSIS, SSIS/SSSS,
  ISSS/SSSS, SISS/SSSS, SSSI/SSSS, SIIS/SSIS}
    \draw [-{Latex[length=2.5mm,width=1mm,angle'=30]}] (\A circ) -- (\B circ);


\foreach \A/\B in {
  IIII/IIIS, IIII/ISII, IIII/SIII, IIII/IISI,
  IISI/IISS, IISI/ISSI, IISI/SISI,
  SSSI/SISI, SSSI/ISSI, SSSI/SSII,
  SIII/SIIS, SIII/SSII, ISSS/ISSI,
  ISII/ISIS, ISII/SSII, ISII/ISSI,
  SISI/SIII, SISI/SISS, SSIS/SSII}
    \draw [{Latex[length=2.5mm,width=1mm,angle'=30]}-{Latex[length=2.5mm,width=1mm,angle'=30]}] (\A circ) -- (\B circ);

\begin{scope}[on background layer]
\draw [line width=40pt,opacity=0.3,red,line cap=round,rounded corners] (IISScirc.center) -- (SIIScirc.center) -- (ISIScirc.center);
\draw [line width=40pt,opacity=0.3,blue,line cap=round,rounded corners] (SSIIcirc.center) -- (ISSIcirc.center) -- (SISIcirc.center);

\coordinate (A) at ($(ISSIcirc)!0.4!(SSIIcirc)$);
\coordinate (B) at ($(IISScirc)!0.6!(SIIScirc)$);
\draw [stealth-stealth,ultra thick,green]  ($(A)!20pt!90:(SSIIcirc)$) -- ($(B)!20pt!90:(IISScirc)$);
\end{scope}

\end{tikzpicture}
\end{document}
  • This looks like it should be able to do what I'm after. If possible, I'd like to be able to put edges between these new "nodes" that I'm trying to create. Is that feasible with this question (apologies for shifting the goal posts a bit, but this is why I was asking if we can create nodes)? – Joel Oct 25 '15 at 15:27
  • @Joel You were asking for a shape, not a node, that makes things more complicated. – Torbjørn T. Oct 25 '15 at 15:43
  • apologies - it was in the question title, but yeah - I complain when people word their questions differently in the title. – Joel Oct 25 '15 at 15:48
  • @Joel Ah, yes, apologies from me as well. I must have read it, but it obviously didn't register. – Torbjørn T. Oct 25 '15 at 15:54
  • 2
    @joel These kind of nodes doesn't exist, but you can declare coordinates at certain pos on a path and use them to draw connections beween them. – Ignasi Oct 25 '15 at 17:21
2

This doesn't attempt to answer your question, but rather demonstrates how one could simplify the code (somewhat) using pics. Specifically, doodle draws everything inside BigCirc, changing the fill colors each time using the new keys Tcolor, Lcolor, Rcolor and Ccolor. Admittedly setting this up required doing more calculations by hand, but much less work for TikZ.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, backgrounds, fit, arrows, arrows.meta}
\definecolor{colorS}{RGB}{0,154,128}
\definecolor{colorI}{RGB}{255,32,0}

\tikzstyle{BigCirc}=[circle,draw=black!50,thick,inner sep=0pt,minimum size=8.8mm, inner sep = 0mm]

\tikzset{% create new tikz keys
  Tcolor/.initial=white,
  Rcolor/.initial=white,
  Lcolor/.initial=white,
  Ccolor/.initial=white}

\tikzset{% create pic doodle
pics/doodle/.style ={code = { %
\draw[-] (0,0.1) -- (0,0.15)
  (-.0866,-.05) -- (-.1299,-.075)
  (.0866,-.05) -- (.1299,-.075);
\path[draw=black!50,thick,fill=\pgfkeysvalueof{/tikz/Ccolor}!90]
  (0,0) circle[radius=1mm];
\path[draw=black!50,thick,fill=\pgfkeysvalueof{/tikz/Tcolor}!90]
  (0,0.25) circle[radius=1mm];
\path[draw=black!50,thick,fill=\pgfkeysvalueof{/tikz/Lcolor}!90]
 (-0.2165,-0.125) circle[radius=1mm];
\path[draw=black!50,thick,fill=\pgfkeysvalueof{/tikz/Rcolor}!90]
 (0.2165,-0.125) circle[radius=1mm];
}}}

\begin{document}
\begin{tikzpicture}

\coordinate (SSSSloc) at (0,0);
\begin{pgfonlayer}{background}
  \pic[Tcolor=colorS,Lcolor=colorS,Rcolor=colorS,Ccolor=colorS] at (SSSSloc) {doodle};
  \node[BigCirc] (SSSS) at (SSSSloc) {};
\end{pgfonlayer}

\pic[Tcolor=colorI,Lcolor=colorI,Rcolor=colorI,Ccolor=colorS] at (1,0) {doodle};

\end{tikzpicture}
\end{document}

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.