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

Clash 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?
pgfplots bar-chart
add a comment |Â
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?
pgfplots bar-chart
add a comment |Â
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?
pgfplots bar-chart
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?
pgfplots bar-chart
asked yesterday
Ribz
30719
30719
add a comment |Â
add a comment |Â
 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

add a comment |Â
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

add a comment |Â
 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

add a comment |Â
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

add a comment |Â
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

"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

answered yesterday
Zarko
109k859147
109k859147
add a comment |Â
add a comment |Â
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

add a comment |Â
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

add a comment |Â
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

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

answered yesterday
marmot
47.8k34293
47.8k34293
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
