4

I am trying to reproduce this image

What I tried is this:

\begin{tikzpicture} 
    \tikzset{every pin/.style={draw,fill=black!0!white,rectangle,rounded corners=3pt,font=\scriptsize},} 
    \begin{axis}[
        x label style={font=\footnotesize},
        y label style={font=\footnotesize}, 
        ticklabel style={font=\footnotesize},
        axis line style={draw=none},
        tick style={draw=none},
        ylabel = {Exaoctets par mois},
        %ylabel style={align=center,rotate=-90},
        bar width=28pt,
        nodes near coords,
        point meta=explicit symbolic,
        ybar,
        x tick label style={/pgf/number format/1000 sep=},]
        \addplot[blue!50!black,fill] coordinates {
            (2016,7) [\footnotesize 7 EO] 
            (2017,11) [\footnotesize 11 EO] 
            (2018,17) [\footnotesize 17 EO]
            (2019,24) [\footnotesize 24 EO]
            (2020,35) [\footnotesize 35 EO]
            (2021,49) [\footnotesize 49 EO]
        }; 
    \end{axis} 
\end{tikzpicture}

I did not succeed to do the legend with the blue sky color (the upper left corner).

How can I do this?

3

"legend" more seems to be title of diagram:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{siunitx}

\begin{document}
\begin{tikzpicture}
 \begin{axis}[
   label style = {font=\footnotesize},
    ticklabel style = {font=\footnotesize},
    axis line style = {draw=none},
         tick style = {draw=none},
    ylabel = {Exaoctets par mois},
    bar width=28pt,
    nodes near coords,
    nodes near coords style={font=\footnotesize},
    point meta=explicit symbolic,
    ybar,
    x tick label style={/pgf/number format/1000 sep=},
    title=\SI{47}{\%} CARG 2016-2021,
    title style = {at={(1,1)}, above, fill=cyan, text=white}
                ]
    \addplot[blue!50!black,fill] coordinates {
        (2016,7)  [7 EO]
        (2017,11) [11 EO]
        (2018,17) [17 EO]
        (2019,24) [24 EO]
        (2020,35) [35 EO]
        (2021,49) [49 EO]
    };
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

4

I am not sure I would use a legend for that. A simple node at current axis.north east does (IMHO) the job as well.

\documentclass[border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}

\begin{tikzpicture} 
    \tikzset{every pin/.style={draw,fill=black!0!white,rectangle,rounded corners=3pt,font=\scriptsize},} 
    \begin{axis}[
        x label style={font=\footnotesize},
        y label style={font=\footnotesize}, 
        ticklabel style={font=\footnotesize},
        axis line style={draw=none},
        tick style={draw=none},
        ylabel = {Exaoctets par mois},
        %ylabel style={align=center,rotate=-90},
        bar width=28pt,
        nodes near coords,
        point meta=explicit symbolic,
        ybar,
        x tick label style={/pgf/number format/1000 sep=},]
        \addplot[blue!50!black,fill] coordinates {
            (2016,7) [\footnotesize 7 EO] 
            (2017,11) [\footnotesize 11 EO] 
            (2018,17) [\footnotesize 17 EO]
            (2019,24) [\footnotesize 24 EO]
            (2020,35) [\footnotesize 35 EO]
            (2021,49) [\footnotesize 49 EO]
        }; 
    \end{axis} 
    \node[anchor=south,fill=blue!30!white,text=white,font=\sffamily,
    inner ysep=7pt] at (current axis.north east)
    {\textbf{47\% CAGR} 2016--2021};
\end{tikzpicture}
\end{document}

enter image description here

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.