How to produce a legend with a specific text and color in a bar chart with pgfplots?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I am trying to reproduce this image



What I tried is this:



begintikzpicture 
tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
beginaxis[
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]
;
endaxis
endtikzpicture


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



How can I do this?







share|improve this question























    up vote
    4
    down vote

    favorite












    I am trying to reproduce this image



    What I tried is this:



    begintikzpicture 
    tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
    beginaxis[
    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]
    ;
    endaxis
    endtikzpicture


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



    How can I do this?







    share|improve this question





















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I am trying to reproduce this image



      What I tried is this:



      begintikzpicture 
      tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
      beginaxis[
      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]
      ;
      endaxis
      endtikzpicture


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



      How can I do this?







      share|improve this question











      I am trying to reproduce this image



      What I tried is this:



      begintikzpicture 
      tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
      beginaxis[
      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]
      ;
      endaxis
      endtikzpicture


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



      How can I do this?









      share|improve this question










      share|improve this question




      share|improve this question









      asked yesterday









      Ribz

      30719




      30719




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          "legend" more seems to be title of diagram:



          documentclass[margin=3mm]standalone
          usepackagepgfplots
          pgfplotssetcompat=1.16
          usepackagesiunitx

          begindocument
          begintikzpicture
          beginaxis[
          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=SI47% 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]
          ;
          endaxis
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer




























            up vote
            4
            down vote













            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
            usepackagepgfplots
            pgfplotssetcompat=1.16
            begindocument

            begintikzpicture
            tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
            beginaxis[
            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]
            ;
            endaxis
            node[anchor=south,fill=blue!30!white,text=white,font=sffamily,
            inner ysep=7pt] at (current axis.north east)
            textbf47% CAGR 2016--2021;
            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer





















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "85"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );








               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f444759%2fhow-to-produce-a-legend-with-a-specific-text-and-color-in-a-bar-chart-with-pgfpl%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote



              accepted










              "legend" more seems to be title of diagram:



              documentclass[margin=3mm]standalone
              usepackagepgfplots
              pgfplotssetcompat=1.16
              usepackagesiunitx

              begindocument
              begintikzpicture
              beginaxis[
              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=SI47% 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]
              ;
              endaxis
              endtikzpicture
              enddocument


              enter image description here






              share|improve this answer

























                up vote
                3
                down vote



                accepted










                "legend" more seems to be title of diagram:



                documentclass[margin=3mm]standalone
                usepackagepgfplots
                pgfplotssetcompat=1.16
                usepackagesiunitx

                begindocument
                begintikzpicture
                beginaxis[
                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=SI47% 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]
                ;
                endaxis
                endtikzpicture
                enddocument


                enter image description here






                share|improve this answer























                  up vote
                  3
                  down vote



                  accepted







                  up vote
                  3
                  down vote



                  accepted






                  "legend" more seems to be title of diagram:



                  documentclass[margin=3mm]standalone
                  usepackagepgfplots
                  pgfplotssetcompat=1.16
                  usepackagesiunitx

                  begindocument
                  begintikzpicture
                  beginaxis[
                  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=SI47% 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]
                  ;
                  endaxis
                  endtikzpicture
                  enddocument


                  enter image description here






                  share|improve this answer













                  "legend" more seems to be title of diagram:



                  documentclass[margin=3mm]standalone
                  usepackagepgfplots
                  pgfplotssetcompat=1.16
                  usepackagesiunitx

                  begindocument
                  begintikzpicture
                  beginaxis[
                  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=SI47% 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]
                  ;
                  endaxis
                  endtikzpicture
                  enddocument


                  enter image description here







                  share|improve this answer













                  share|improve this answer



                  share|improve this answer











                  answered yesterday









                  Zarko

                  109k859147




                  109k859147




















                      up vote
                      4
                      down vote













                      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
                      usepackagepgfplots
                      pgfplotssetcompat=1.16
                      begindocument

                      begintikzpicture
                      tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
                      beginaxis[
                      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]
                      ;
                      endaxis
                      node[anchor=south,fill=blue!30!white,text=white,font=sffamily,
                      inner ysep=7pt] at (current axis.north east)
                      textbf47% CAGR 2016--2021;
                      endtikzpicture
                      enddocument


                      enter image description here






                      share|improve this answer

























                        up vote
                        4
                        down vote













                        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
                        usepackagepgfplots
                        pgfplotssetcompat=1.16
                        begindocument

                        begintikzpicture
                        tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
                        beginaxis[
                        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]
                        ;
                        endaxis
                        node[anchor=south,fill=blue!30!white,text=white,font=sffamily,
                        inner ysep=7pt] at (current axis.north east)
                        textbf47% CAGR 2016--2021;
                        endtikzpicture
                        enddocument


                        enter image description here






                        share|improve this answer























                          up vote
                          4
                          down vote










                          up vote
                          4
                          down vote









                          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
                          usepackagepgfplots
                          pgfplotssetcompat=1.16
                          begindocument

                          begintikzpicture
                          tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
                          beginaxis[
                          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]
                          ;
                          endaxis
                          node[anchor=south,fill=blue!30!white,text=white,font=sffamily,
                          inner ysep=7pt] at (current axis.north east)
                          textbf47% CAGR 2016--2021;
                          endtikzpicture
                          enddocument


                          enter image description here






                          share|improve this answer













                          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
                          usepackagepgfplots
                          pgfplotssetcompat=1.16
                          begindocument

                          begintikzpicture
                          tikzsetevery pin/.style=draw,fill=black!0!white,rectangle,rounded corners=3pt,font=scriptsize,
                          beginaxis[
                          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]
                          ;
                          endaxis
                          node[anchor=south,fill=blue!30!white,text=white,font=sffamily,
                          inner ysep=7pt] at (current axis.north east)
                          textbf47% CAGR 2016--2021;
                          endtikzpicture
                          enddocument


                          enter image description here







                          share|improve this answer













                          share|improve this answer



                          share|improve this answer











                          answered yesterday









                          marmot

                          47.8k34293




                          47.8k34293






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f444759%2fhow-to-produce-a-legend-with-a-specific-text-and-color-in-a-bar-chart-with-pgfpl%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              What is the equation of a 3D cone with generalised tilt?

                              Color the edges and diagonals of a regular polygon

                              Relationship between determinant of matrix and determinant of adjoint?