3

I’m trying to create a presentation about Apache Cassandra and draw what they call a ring which shows which nodes store which ranges of partition key.

I wanted to express this ranges as colour ranges.

After that I wanted to show how replication factor makes node to store more ranges by drawing overlapping rainbows with shifted colours.

But so far I’ve only managed to draw two rings without overlap.

I would also like to automate this to replication factor of more than three and any number of nodes (I’ve struggled with \foreach, but the node labels were shifted by x and y axis and out of sync with circles).

I’m a novice as far as tikz and latex, maybe I should just drop this idea, because all this custom shading solutions I’ve googled seem very complex…

I would appreciate help. Solution should be preferably as simple as possible.

\tikz \shade[shading=color wheel] [even odd rule]
       (0,2) circle [radius=2.4]
       (0,2) circle [radius=2.2]
       (0,2) circle [radius=2.0]
       (0,2) circle [radius=1.8];

Result

2
  • So let me double check. That fact that you (currently) have two rings means replication factor = 2, which means every data point/key/color/whatever_unit_of_data has two copies, each stored in different nodes?
    – Symbol 1
    Aug 3, 2021 at 19:49
  • Yes, and I would prefer not to manually calculate all the angles to set node labels for different number of nodes and replication factors. Aug 3, 2021 at 19:54

2 Answers 2

5
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
  \shade[shading=color wheel, even odd rule, shading angle=20] (0,0) circle[radius=2.4] (0,0) circle[radius=2.2];
  \shade[shading=color wheel, even odd rule] (0,0) circle[radius=2.0] (0,0) circle[radius=1.8];
  \node at (20:2.8) {$N1$};
  \node at (220:2.8) {$N2$};
  \node at (140:2.8) {$N3$};
  \draw[thick] (80:1.8) -- (80:2.4);
  \draw[thick] (180:1.8) -- (180:2.4);
  \draw[thick] (290:1.8) -- (290:2.4);
  \draw[thick] (40:2.3) -- (40:3) node[above, align=left, font=\tiny] {Is rotated to\\overlap ranges};
\end{tikzpicture}
\end{document}

Two colorwheels

5

Not sure if this is what you want?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}

\tikz{
    \shade[shading=color wheel,even odd rule]
        circle[radius=2.4]circle[radius=2.2];
    \shade[shading=color wheel,even odd rule,transform canvas={rotate=72}]
        circle[radius=2]circle[radius=1.8];
    \foreach\NODE in{1,2,3,4,5}{
        \draw
            (\NODE*72:1.6)--(\NODE*72:2.6)
            (\NODE*72+36:3)node{node \#\NODE}
        ;
    }
}

\end{document}

3
  • +1. transform canvas is very dramatic :o) and problematic, if OP wants the center not to be at (0,0) as indicated in OP code. Aug 3, 2021 at 20:03
  • Thanks for you help, I will stick with `shading angles for now, though. Aug 3, 2021 at 20:07
  • Ah yes, I should have thought that there is a key for angling the shading. Thanks for the reminder.
    – Symbol 1
    Aug 3, 2021 at 20:39

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.