2

I am currently "modelling" a spider web diagram. I need to visualize decimal numbers like 8.95. On the internet, I have found a very good solution to model a spider web diagram. Unfortunately, all decimal numbers will be rounded which gives a wrong visualization result in the diagram.

I tried two things with no success:

  • Increased the scale from 0-15 (value 8.95) to 0-1500 (value 895)
  • \begin{tikzpicture}[scale=1,x=15.0,y=15.0]

Does anyone know, how to allow decimal numbers in the spider web? Thanks a lot in advance!

Here a MWE:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Spiderweb Diagram
%
% Author: Dominik Renzel
% Date; 2009-11-11
\documentclass{article}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage,floats]{preview}
\setlength\PreviewBorder{5pt}%
%%%>

\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}

\newcommand{\D}{7} % number of dimensions (config option)
\newcommand{\U}{7} % number of scale units (config option)

\newdimen\R % maximal diagram radius (config option)
\R=3.5cm 
\newdimen\L % radius to put dimension labels (config option)
\L=4cm

\newcommand{\A}{360/\D} % calculated angle between dimension axes  

\begin{figure}[htbp]
 \centering

\begin{tikzpicture}[scale=1]
  \path (0:0cm) coordinate (O); % define coordinate for origin

  % draw the spiderweb
  \foreach \X in {1,...,\D}{
    \draw (\X*\A:0) -- (\X*\A:\R);
  }

  \foreach \Y in {0,...,\U}{
    \foreach \X in {1,...,\D}{
      \path (\X*\A:\Y*\R/\U) coordinate (D\X-\Y);
      \fill (D\X-\Y) circle (1pt);
    }
    \draw [opacity=0.3] (0:\Y*\R/\U) \foreach \X in {1,...,\D}{
        -- (\X*\A:\Y*\R/\U)
    } -- cycle;
  }

  % define labels for each dimension axis (names config option)
  \path (1*\A:\L) node (L1) {\tiny Security};
  \path (2*\A:\L) node (L2) {\tiny Content Quality};
  \path (3*\A:\L) node (L3) {\tiny Performance};
  \path (4*\A:\L) node (L4) {\tiny Stability};
  \path (5*\A:\L) node (L5) {\tiny Usability};
  \path (6*\A:\L) node (L6) {\tiny Generality};
  \path (7*\A:\L) node (L7) {\tiny Popularity};

  % Example Case (blue)
  \draw [color=blue,line width=1.5pt,opacity=0.5]
    (D1-1.5) --
    (D2-6.5) --
    (D3-4.2) --
    (D4-4.8) --
    (D5-3.6) --
    (D6-5.1) --
    (D7-2.3) -- cycle;

\end{tikzpicture}
\caption{Spiderweb Diagram (\D~Dimensions, \U-Notch Scale, 3 Samples)}
\label{fig:spiderweb}
\end{figure}

\end{document}
7
  • It would be helpful if you could provide a link to the very good solution you found on the internet. Or is your MWE the example you found?
    – DJP
    Jan 25, 2018 at 15:20
  • Hi, I've attached the MWE which is from the solution. Here's the link to the source: texample.net/tikz/examples/spiderweb-diagram
    – HB4711
    Jan 25, 2018 at 15:23
  • Could you please explain in more detail what you want? Which value/quantity do you want to set to 8.95?
    – user121799
    Jan 25, 2018 at 15:26
  • As you can see in the MWE, all the draws have decimal values (D1 has 1.5, D2 has 6.5, and so on). But the visualization of the spider web won't show these decimal values - TikZ is rounding (or rather cutting) these values. D1 will be shown as 1, D2 as 6, and so on. But I would like to have the exact decimal values in the spider web. The 8.95 was just an example from my model (sry for that :) )
    – HB4711
    Jan 25, 2018 at 15:36
  • @HB4711 I think you're misinterpreting these coordinate specifications. For instance, (D5-3.6) means the coordinate (D5-3) with a rotation by 6 degrees. I think that the .6 doesn't have any effect here. It does when you have extended objects such as nodes. (Of course, I could be wrong.) Could you please describe in detail what you want to achieve?
    – user121799
    Jan 25, 2018 at 15:53

1 Answer 1

4

You can achieve what you want by "mixing" nodes using the calc library. I added 3 examples to you snippet, two in which the node is set right in the middle between two, and one where the second node contributes 85%, which is probably you meant by 4.85.

\documentclass{article}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage,floats]{preview}
\setlength\PreviewBorder{5pt}%
%%%>

\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{calc}%<-added

\begin{document}

\newcommand{\D}{7} % number of dimensions (config option)
\newcommand{\U}{7} % number of scale units (config option)

\newdimen\R % maximal diagram radius (config option)
\R=3.5cm 
\newdimen\L % radius to put dimension labels (config option)
\L=4cm

\newcommand{\A}{360/\D} % calculated angle between dimension axes  

\begin{figure}[htbp]
 \centering

\begin{tikzpicture}[scale=1]
  \path (0:0cm) coordinate (O); % define coordinate for origin

  % draw the spiderweb
  \foreach \X in {1,...,\D}{
    \draw (\X*\A:0) -- (\X*\A:\R);
  }

  \foreach \Y in {0,...,\U}{
    \foreach \X in {1,...,\D}{
      \path (\X*\A:\Y*\R/\U) coordinate (D\X-\Y);
      \fill (D\X-\Y) circle (1pt);
    }
    \draw [opacity=0.3] (0:\Y*\R/\U) \foreach \X in {1,...,\D}{
        -- (\X*\A:\Y*\R/\U)
    } -- cycle;
  }

  % define labels for each dimension axis (names config option)
  \path (1*\A:\L) node (L1) {\tiny Security};
  \path (2*\A:\L) node (L2) {\tiny Content Quality};
  \path (3*\A:\L) node (L3) {\tiny Performance};
  \path (4*\A:\L) node (L4) {\tiny Stability};
  \path (5*\A:\L) node (L5) {\tiny Usability};
  \path (6*\A:\L) node (L6) {\tiny Generality};
  \path (7*\A:\L) node (L7) {\tiny Popularity};

  % Example Case (blue)
  \draw [color=blue,line width=1.5pt,opacity=0.5]
    ($(D1-1)!0.5!(D1-2)$) --
    (D2-6.5) --
    (D3-4.2) --
    ($(D4-4)!0.85!(D4-5)$) --
    (D5-3.6) --
    (D6-5.1) --
    (D7-2.3) -- cycle;

\end{tikzpicture}
\caption{Spiderweb Diagram (\D~Dimensions, \U-Notch Scale, 3 Samples)}
\label{fig:spiderweb}
\end{figure}

\end{document}

enter image description here

6
  • This one looks very good! I try to adapt this in my project! Thank you very much :)
    – HB4711
    Jan 25, 2018 at 16:27
  • It works (of course) for my project as well and is exactly what I want. You are a god :) Thanks again!
    – HB4711
    Jan 25, 2018 at 16:29
  • A coordinate like (D2-6.5) is strictly equivalent to (D2-6). This is not the case with nodes... Jan 25, 2018 at 23:22
  • @PaulGaborit So you agree with my comment above? "I think you're misinterpreting these coordinate specifications. For instance, (D5-3.6) means the coordinate (D5-3) with a rotation by 6 degrees. I think that the .6 doesn't have any effect here. It does when you have extended objects such as nodes. "
    – user121799
    Jan 25, 2018 at 23:23
  • @marmot Yes (I did not notice your comment). You can probably change the code to remove these unnecessary angles ... Jan 25, 2018 at 23:27

You must log in to answer this question.

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