4

I want to draw this graph. enter image description here

First of all. Is there a package for graphs like this? Or should I interpret this as a figure (graphic (?) ) that I have to draw piece by piece in tikz or pgf?

I do not include a MWE, because I would like to know in which direction I must think for making this figure. Any advice is very much appreciated!

Extra info added: In the end, I want to adapt the graphic and make similar graphics.

4
  • Perhaps it would be easier to draw this graph in an external program and then load it in LaTeX with \includegraphics.
    – Jinwen
    Commented May 27, 2022 at 8:16
  • @Jinwen Would be nice, but I want to adapt the graphic and make similar graphics. Commented May 27, 2022 at 8:27
  • I think TikZ is a good choice. Your figure is simple but maybe long in coding. Which part of the figure made you stuck?
    – Black Mild
    Commented May 27, 2022 at 19:43
  • @BlackMild Not a part in particular. I'm pretty experienced in drawing in Tikz, but I was wandering I've there might be something new to learn :-) Commented May 28, 2022 at 7:54

2 Answers 2

3

enter image description here

I think, one possibility would be to define pics to control the entries in your diagram. In the code below, I'm dealing only with those entries that are composed of a colored strip and some text either above, or below it; there is also the way the text is aligned with respect to the strip yielding two pics for "text above" and two for "text below".

Remark. In the pic named below-left (or -right), the last argument controls the length of the text in case it is longer than the colored strip. If not, that argument should be set to 0. Maybe something similar might be needed for the above-left (or -right) in your diagrams.

The code

\documentclass[11pt, margin=1cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{math}

\begin{document}

\tikzmath{
  real \w;
  \w = .2;
}
\tikzset{pics/.cd,
  above-left/.style args={color=#1, length=#2, text=#3, label=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (0, \w +.1)
      node[above right, minimum width=#2,
      text width=\tw cm, align=left,
      inner xsep=.1cm, inner ysep=0,
      label={[minimum width=#2, align=left,
        text width=\tw cm]90:{\tiny\mbox{#4}}
      }, label distance=3pt]
      {\tiny #3};
    }
  },
  above-right/.style args={color=#1, length=#2, text=#3, label=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (#2, \w +.1)
      node[above left, minimum width=#2,
      text width=\tw cm, align=right,
      inner xsep=.1cm, inner ysep=0,
      label={[minimum width=#2, align=right,
        text width=\tw cm]90:{\tiny\mbox{#4}}
      }, label distance=3pt]
      {\tiny #3};
    }
  },
  below-left/.style args={color=#1, length=#2, text=#3, delta=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2 +#4;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (0, -.1)
      node[below right, minimum width=#2,
      text width=\tw cm, align=left,
      inner xsep=.1cm, inner ysep=0]
      {\tiny #3};
    }
  },
  below-right/.style args={color=#1, length=#2, text=#3, delta=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2 +#4;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (#2, -.1)
      node[below left, minimum width=#2,
      text width=\tw cm, align=right,
      inner xsep=.1cm, inner ysep=0]
      {\tiny #3};
    }
  }
}

\begin{tikzpicture}
  \foreach \t [count=\i from 0] in
  {10 nm, 100 nm, 1\mu m, 10\mu m, 100\mu m, 1 mm, 10 mm}{%
    \draw[gray, very thin] (1.5*\i, .2)
    node[above, minimum height=4ex, inner ysep=1ex, scale=.8, text=black] {$\t$}
    -- ++(0, -10.4); 
  } 
  \draw[ultra thick] (-.2, 0) -- (9.2, 0);

  %% the pics
  \path (5, -2) pic {below-left={color=red!80!black, length=1.5,
    text={Unicellular \\[-5pt] marine algae},
    delta=2}};
  \path (5, -4) pic {below-right={color=red!80!black, length=1,
    text={Human \\[-5pt] macrophage},
    delta=2}};
  \path (.1, -7) pic {above-right={color=black!70, length=3,
    text={Py-GCMS$^\ast$ \\[-5pt]
      (\$\,200,000-300,000)},
    label={$<1\mu m$}}};
  \path (2, -9) pic {above-left={color=black!70, length=7,
    text={Micro-Raman spectroscopy (>50,000 \$) \\[-5pt]
      (Black or dark colored particles cannot be identified)},
    label={$>1\mu m$}}};
\end{tikzpicture}
\end{document}
2

Thanks to Daniel I found the answer! I added the logarithmic scale and a variation on the text block.

\documentclass[11pt, margin=1cm]{article}

\usepackage{tikz}
\usetikzlibrary{math}
\usepackage{pgfplots}
\usepackage{siunitx}

\begin{document}

\tikzmath{
  real \w;
  \w = .2;
}
\tikzset{pics/.cd,
  above-left/.style args={color=#1, length=#2, text=#3, label=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (0, \w +.1)
      node[above right, minimum width=#2,
      text width=\tw cm, align=left,
      inner xsep=.1cm, inner ysep=0,
      label={[minimum width=#2, align=left,
        text width=\tw cm]90:{\tiny\mbox{#4}}
      }, label distance=3pt]
      {\tiny #3};
    }
  },
  above-right/.style args={color=#1, length=#2, text=#3, label=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (#2, \w +.1)
      node[above left, minimum width=#2,
      text width=\tw cm, align=right,
      inner xsep=.1cm, inner ysep=0,
      label={[minimum width=#2, align=right,
        text width=\tw cm]90:{\tiny\mbox{#4}}
      }, label distance=3pt]
      {\tiny #3};
    }
  },
  inside-bar/.style args={color=#1, length=#2, text=#3, delta=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2 +#4;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/7, 2.6*\w);
      \fill[#1] (#2/7, 0) rectangle ++(#2*5/7, 2.6*\w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/7, 2.6*\w);
      \path (#2/2, 1.3*\w)
      node[minimum width=#2,white,
      text width=\tw cm, align=center,
      inner xsep=.1cm, inner ysep=0]
      {\footnotesize #3};
    }
  },
  below-left/.style args={color=#1, length=#2, text=#3, delta=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2 +#4;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (0, -.1)
      node[below right, minimum width=#2,
      text width=\tw cm, align=left,
      inner xsep=.1cm, inner ysep=0]
      {\tiny #3};
    }
  },
  below-right/.style args={color=#1, length=#2, text=#3, delta=#4}{
    code={
      \tikzmath{
        real \tw;
        \tw = #2 -.2 +#4;
      }
      \path[shade, left color=white, right color=#1]
      (0, 0) rectangle ++(#2/5, \w);
      \fill[#1] (#2/5, 0) rectangle ++(#2*3/5, \w);
      \path[shade,  left color=#1, right color=white]
      (#2*4/5, 0) rectangle ++(#2/5, \w);
      \path (#2, -.1)
      node[below left, minimum width=#2,
      text width=\tw cm, align=right,
      inner xsep=.1cm, inner ysep=0]
      {\tiny #3};
    }
  }
}





\begin{tikzpicture}
    \begin{axis}%
        [
    xmode=log,
    log ticks with fixed point,
           grid=both,  
%           axis line style={thick},
            %xtick distance = 0.5,
            ytick distance = 10,
            %minor x tick num=0,
            %minor y tick num=0,
            x=0.87cm,   y=1cm,
            xmin=0.01, xmax=10000,
            %minor x tick num={1},
            tick label style={font=\tiny},
            ymin=0, ymax=10,
          xticklabels=\empty,
          yticklabels=\empty,
        ]
    \end{axis}

  \foreach \t [count=\i from 0] in
  {\SI{10}{\mm}, \SI{100}{\nm}, \SI{1}{\micro\m}, \SI{10}{\micro\m}, \SI{100}{\micro\m}, \SI{1}{\mm}, \SI{10}{\mm}}{%
    \draw[black] (2*\i, 10) node[above, minimum height=4ex, inner ysep=1ex, scale=.8, text=black] {$\t$} --++ (0,-10); 
    \draw[gray, very thin, dashed] (2*\i, -.2)
    node[below, minimum height=4ex, inner ysep=1ex, scale=.8, text=black] {$\t$}; 
  } 
  %\draw[ultra thick] (-.2, 0) --++ (10.4, 0);
  %\draw[ultra thick] (-.2, -8) --++ (10.4, 0);


    % onderscheid plastics
   \path (0, 10.7) pic {inside-bar={color=orange!80!black, length=4, text={Nanoplastics}, delta=2}};
   \path (4, 10.7) pic {inside-bar={color=orange!80!black, length=8, text={Microplastics}, delta=2}};

  %% De balkjes
  \path (10, 8.5) pic {above-left={color=black!70, length=2, text={Naked-eye}, label={$> \SI{1}{\mm}$}}};
  \path (8, 7) pic {above-left={color=black!70, length=4, text={Optical microscope\\[-5pt] (\$ \num{700}$-$\num{3000})}, label={$> \SI{1}{\mm}$}}};
  \path (0, 5) pic {above-left={color=black!70, length=4.2, text={Py-GCMS$^\ast$ \\[-5pt] (\$ \num{200000}$-$\num{300000})},
    label={$< \SI{1}{\micro\m}$}}};
  \path (6, 5) pic {above-left={color=black!70, length=6, text={FTIR \\[-5pt] (\$ \num{25000})},
    label={$> \SI{10}{\micro\m}-\SI{20}{\micro\m}$}}};
  \path (3.8, 3) pic {above-left={color=black!70, length=8.2, text={Micro-Raman spectroscopy ($ >\$\num{50000}$) \\[-5pt] (Black or dark colored particles cannot be identified)}, label={$>\SI{1}{\micro\m}$}}};

  \path (4.6, 1) pic {above-left={color=black!70, length=7.4, text={Nile red staining + fluorescence micorsocopy\\[-5pt] ($ >\$\num{2000}-\num{50000}$)  }, label={$>\SI{3}{\micro\m}$}}};
\end{tikzpicture}
\end{document}

enter image description here

1
  • Tip: You can use font=\tiny to specify the font size of the node text. Then you can remove \tiny inside the node text.
    – Unknown
    Commented May 28, 2022 at 15:57

You must log in to answer this question.

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