pgfplots/tickz barra de un solo color con tirantes

pgfplots/tickz barra de un solo color con tirantes

Soy totalmente nuevo en tickz/pgfplot y mi objetivo es hacer una sola barra horizontal (con llaves) como esta:

ingrese la descripción de la imagen aquí

Supongo que prefiero empezar con pgfplotscolorbardrawstandalone, sin embargo, el resto es una verdadera lucha para mí. ¿Alguien podría ayudar?

Respuesta1

Con Ti purokZ (no es muy simple...)Č

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, chains,
                decorations.pathreplacing, % must be after decorations.pathreplacing
                calligraphy
                }

\begin{document}
    \begin{tikzpicture}[
    node distance = 0pt,
      start chain = A going right,
      start chain = B going right,
BC/.style args = {#1/#2}{
    decorate,
    decoration={calligraphic brace, amplitude=6pt,
    pre =moveto, pre  length=1pt,
    post=moveto, post length=1pt,
    raise=#1},
    very thick,
    pen colour={#2}
    },
BL/.style = {font=\small, below=#1},
 M/.style args = {#1/#2}{baseline, fill=#1, 
    font=\small, label={[text height=1.2ex, text depth=0.2ex]right:#2}, 
    node distance=17mm},
 N/.style args = {#1/#2}{fill=#1, minimum width=#2, 
    minimum height=5mm, outer sep=0pt, node contents={}, 
    on chain=B},
                        ]

\node (a) [N=red/30mm];
\node (b) [N=orange/85mm];
\node (c) [N=purple/10mm];

\path   ([yshift=5mm] a.north west) --
    node (x) [M=orange/orange] {}
    node     [M=red/red, left=of x] {}
    node     [M=purple/purple, right=of x] {}
        ([yshift=5mm] c.north east);
    
\draw[BC=3pt/black] (a.south east) -- node[BL=7pt] {length = 30} (a.south west);
\draw[BC=3pt/black] (b.south east) -- node[BL=7pt] {length = 85} (b.south west);
\draw[BC=3pt/black] (c.south east) -- node[BL=7pt] {length = 10} (c.south west);
    \end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

Apéndice: Con pgfplotsel código es un poco más sencillo y mucho más corto:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc, chains,
                decorations.pathreplacing, % must be after decorations.pathreplacing
                calligraphy
                }
\pgfplotsset{compat=1.18}


\begin{document}
    \begin{tikzpicture}[
BC/.style = {
    decorate,
    decoration={calligraphic brace, amplitude=6pt,
    pre =moveto, pre  length=1pt,
    post=moveto, post length=1pt,
    raise=#1, mirror},
    very thick,
    pen colour={black}
    },
BL/.style = {font=\small, below=#1},
BL/.default= 5mm
                    ]
\begin{axis}[
x=1mm, 
axis lines=none,
%
xbar stacked,
bar width=5mm,
xmin=0,
%
legend style={at={(0.5,0.58)}, draw=none, anchor=south,
              legend columns=-1, font=\small,
              /tikz/every even column/.append style={column sep=1em}
              },
                ]
\addplot coordinates{(30,0)};
\addplot coordinates{(85,0)};
\addplot coordinates{(10,0)};
    \legend{blue, red, brown}
%
\draw[BC=3.3mm] (0,  0) -- node[BL] {length = 30} ++(30,0);
\draw[BC=3.3mm] (30, 0) -- node[BL] {length = 85} ++(85,0);
\draw[BC=3.3mm] (115,0) -- node[BL] {length = 10} ++(10,0);
\end{axis}
    \end{tikzpicture}
\end{document}

El resultado es similar al anterior:

ingrese la descripción de la imagen aquí

información relacionada