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}
Sebastiano
  • 54,118
HB4711
  • 99
  • 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 '18 at 15:20
  • Hi, I've attached the MWE which is from the solution. Here's the link to the source: http://www.texample.net/tikz/examples/spiderweb-diagram/ – HB4711 Jan 25 '18 at 15:23
  • Could you please explain in more detail what you want? Which value/quantity do you want to set to 8.95? –  Jan 25 '18 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 '18 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? –  Jan 25 '18 at 15:53
  • Oh, I didn't know that. I thought it means that the node D5 should be on value 3.6... I want to achieve that a specific point of a spider web dimension (e.g. D5) is on a decimal value. Try out the MWE: D5 is named as "Usability" in the spider web. D5 lays on the value 3 in the spider web. But I want to have it (for example) on 3.6. Imagine you want to show tire pressure on a dimension in a spider web. It should be possible to show decimal values (2.0 bar, 2.1 bar, 2.2 bar, etc.) and not only 1 bar, 2 bar etc. – HB4711 Jan 25 '18 at 16:05
  • Related: https://tex.stackexchange.com/questions/399902/problem-spiderweb-diagram-with-csvsimple/399919#399919 – Torbjørn T. Jan 25 '18 at 21:57

1 Answers1

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

  • This one looks very good! I try to adapt this in my project! Thank you very much :) – HB4711 Jan 25 '18 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 '18 at 16:29
  • A coordinate like (D2-6.5) is strictly equivalent to (D2-6). This is not the case with nodes... – Paul Gaborit Jan 25 '18 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. " –  Jan 25 '18 at 23:23
  • @marmot Yes (I did not notice your comment). You can probably change the code to remove these unnecessary angles ... – Paul Gaborit Jan 25 '18 at 23:27
  • @PaulGaborit I thought about that but then I was thinking that the comparison will help to avoid confusion in the future. However, I don't have strong feelings either. Anyway, now this has been clarified in comments below question and answer. –  Jan 25 '18 at 23:30