pgfplots: How to control and align legend items precisely above each other?pgfplots: How to align legends of multigraph diagram?pgfplots particular legendplotting two time series with boundsGrouped bar chartpgfplots : Row title in legendHow to hide empty (value 0) ybars with pgfplots?Show mark labels near marks and not centered in ybar interaval graphpgfplots: percentage in matrix plotCenter the axes in the coordinate originPgfplots: wrong legend imagepgfplots: How to align legends of multigraph diagram?

Should I assume I have passed probation?

Personal or impersonal in a technical resume

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

Origin of pigs as a species

What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?

How do you justify more code being written by following clean code practices?

The Digit Triangles

How do I fix the group tension caused by my character stealing and possibly killing without provocation?

Why does a 97 / 92 key piano exist by Bösendorfer?

Can you identify this lizard-like creature I observed in the UK?

What does "tick" mean in this sentence?

What is the meaning of "You've never met a graph you didn't like?"

Animation: customize bounce interpolation

Why the "ls" command is showing the permissions of files in a FAT32 partition?

Does Doodling or Improvising on the Piano Have Any Benefits?

Echo with obfuscation

Limit max CPU usage SQL SERVER with WSRM

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

Can I say "fingers" when referring to toes?

Why is the sun approximated as a black body at ~ 5800 K?

I'm just a whisper. Who am I?

How to get directions in deep space?

Identifying "long and narrow" polygons in with PostGIS

Review your own paper in Mathematics



pgfplots: How to control and align legend items precisely above each other?


pgfplots: How to align legends of multigraph diagram?pgfplots particular legendplotting two time series with boundsGrouped bar chartpgfplots : Row title in legendHow to hide empty (value 0) ybars with pgfplots?Show mark labels near marks and not centered in ybar interaval graphpgfplots: percentage in matrix plotCenter the axes in the coordinate originPgfplots: wrong legend imagepgfplots: How to align legends of multigraph diagram?













1















The user marmot has posted a really nice approach of adding legend items into one single box below a multigraph diagram by placing them inside a node.



Based on this initial situation I have tried to separate the legend items into three rows above each other, but the result is missleading.




Minimum Working Example (MWE):



documentclass[border=5mm]standalone
usepackagepgfplots
usetikzlibrarypositioning
pgfplotssetcompat=newest, scale only axis
begindocument

begintikzpicture
beginscope[local bounding box=plots]
beginaxis[
axis y line* = left,
legend to name = legA,
legend style = draw=none,
legend columns = 3,
/tikz/every even column/.append style = column sep=0.5cm,
/tikz/every odd column/.append style = column sep=0.15cm,
,
]%
addplot coordinates (0,0) (1,1);
addplot coordinates (1,0) (0,1);
addplot coordinates (0,1) (1,1);
legendGraph 1, Graph 2, Graph 3;
endaxis%
%
beginaxis[
axis x line = none,
axis y line* = right,
legend to name = legB,
legend style = draw=none,
legend columns = 3,
/tikz/every even column/.append style = column sep=0.5cm,
/tikz/every odd column/.append style = column sep=0.15cm,
,
]%
addplot coordinates (0,1) (1,0);
addplot coordinates (0,0.5) (1,0.5);
addplot coordinates (0,0.15) (1,0.15);
legendGraphinggraph 4, Graphinggraph 5, Graphinggraph 6;
endaxis%
%
beginaxis[
axis x line = none,
axis y line* = right,
legend to name = legC,
legend style = draw=none,
legend columns = 3,
/tikz/every even column/.append style = column sep=0.5cm,
/tikz/every odd column/.append style = column sep=0.15cm,
,
]%
pgfplotsset%
%
every outer y axis line/.style = xshift=2cm,
every tick/.style = xshift=2cm,
every y tick label/.style = xshift=2cm,
%
addplot coordinates (0.5,0) (0.5,1);
addplot coordinates (0.6,0) (0.6,1);
addplot coordinates (0.7,0) (0.7,1);
legendGraphgraph 7, Graphgraph 8, Graphgraph 9;
endaxis%
endscope
node[below=3.5em of plots.south] (legA) reflegA;
node[below=-0.5em of legA] (legB) reflegB;
node[below=-0.5em of legB] (legC) reflegC;
draw (legA.north west) rectangle (legC.south east);
endtikzpicture
enddocument



Screenshot of the result:



Screenshot of the result




Description of the issue:



As you can see,



  • the border does not fit with the outer dimension of the legend items,

  • the legend items are not precisely aligned below each other.

So my questions are: How to solve this and make it look nice?










share|improve this question




























    1















    The user marmot has posted a really nice approach of adding legend items into one single box below a multigraph diagram by placing them inside a node.



    Based on this initial situation I have tried to separate the legend items into three rows above each other, but the result is missleading.




    Minimum Working Example (MWE):



    documentclass[border=5mm]standalone
    usepackagepgfplots
    usetikzlibrarypositioning
    pgfplotssetcompat=newest, scale only axis
    begindocument

    begintikzpicture
    beginscope[local bounding box=plots]
    beginaxis[
    axis y line* = left,
    legend to name = legA,
    legend style = draw=none,
    legend columns = 3,
    /tikz/every even column/.append style = column sep=0.5cm,
    /tikz/every odd column/.append style = column sep=0.15cm,
    ,
    ]%
    addplot coordinates (0,0) (1,1);
    addplot coordinates (1,0) (0,1);
    addplot coordinates (0,1) (1,1);
    legendGraph 1, Graph 2, Graph 3;
    endaxis%
    %
    beginaxis[
    axis x line = none,
    axis y line* = right,
    legend to name = legB,
    legend style = draw=none,
    legend columns = 3,
    /tikz/every even column/.append style = column sep=0.5cm,
    /tikz/every odd column/.append style = column sep=0.15cm,
    ,
    ]%
    addplot coordinates (0,1) (1,0);
    addplot coordinates (0,0.5) (1,0.5);
    addplot coordinates (0,0.15) (1,0.15);
    legendGraphinggraph 4, Graphinggraph 5, Graphinggraph 6;
    endaxis%
    %
    beginaxis[
    axis x line = none,
    axis y line* = right,
    legend to name = legC,
    legend style = draw=none,
    legend columns = 3,
    /tikz/every even column/.append style = column sep=0.5cm,
    /tikz/every odd column/.append style = column sep=0.15cm,
    ,
    ]%
    pgfplotsset%
    %
    every outer y axis line/.style = xshift=2cm,
    every tick/.style = xshift=2cm,
    every y tick label/.style = xshift=2cm,
    %
    addplot coordinates (0.5,0) (0.5,1);
    addplot coordinates (0.6,0) (0.6,1);
    addplot coordinates (0.7,0) (0.7,1);
    legendGraphgraph 7, Graphgraph 8, Graphgraph 9;
    endaxis%
    endscope
    node[below=3.5em of plots.south] (legA) reflegA;
    node[below=-0.5em of legA] (legB) reflegB;
    node[below=-0.5em of legB] (legC) reflegC;
    draw (legA.north west) rectangle (legC.south east);
    endtikzpicture
    enddocument



    Screenshot of the result:



    Screenshot of the result




    Description of the issue:



    As you can see,



    • the border does not fit with the outer dimension of the legend items,

    • the legend items are not precisely aligned below each other.

    So my questions are: How to solve this and make it look nice?










    share|improve this question


























      1












      1








      1








      The user marmot has posted a really nice approach of adding legend items into one single box below a multigraph diagram by placing them inside a node.



      Based on this initial situation I have tried to separate the legend items into three rows above each other, but the result is missleading.




      Minimum Working Example (MWE):



      documentclass[border=5mm]standalone
      usepackagepgfplots
      usetikzlibrarypositioning
      pgfplotssetcompat=newest, scale only axis
      begindocument

      begintikzpicture
      beginscope[local bounding box=plots]
      beginaxis[
      axis y line* = left,
      legend to name = legA,
      legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      /tikz/every odd column/.append style = column sep=0.15cm,
      ,
      ]%
      addplot coordinates (0,0) (1,1);
      addplot coordinates (1,0) (0,1);
      addplot coordinates (0,1) (1,1);
      legendGraph 1, Graph 2, Graph 3;
      endaxis%
      %
      beginaxis[
      axis x line = none,
      axis y line* = right,
      legend to name = legB,
      legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      /tikz/every odd column/.append style = column sep=0.15cm,
      ,
      ]%
      addplot coordinates (0,1) (1,0);
      addplot coordinates (0,0.5) (1,0.5);
      addplot coordinates (0,0.15) (1,0.15);
      legendGraphinggraph 4, Graphinggraph 5, Graphinggraph 6;
      endaxis%
      %
      beginaxis[
      axis x line = none,
      axis y line* = right,
      legend to name = legC,
      legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      /tikz/every odd column/.append style = column sep=0.15cm,
      ,
      ]%
      pgfplotsset%
      %
      every outer y axis line/.style = xshift=2cm,
      every tick/.style = xshift=2cm,
      every y tick label/.style = xshift=2cm,
      %
      addplot coordinates (0.5,0) (0.5,1);
      addplot coordinates (0.6,0) (0.6,1);
      addplot coordinates (0.7,0) (0.7,1);
      legendGraphgraph 7, Graphgraph 8, Graphgraph 9;
      endaxis%
      endscope
      node[below=3.5em of plots.south] (legA) reflegA;
      node[below=-0.5em of legA] (legB) reflegB;
      node[below=-0.5em of legB] (legC) reflegC;
      draw (legA.north west) rectangle (legC.south east);
      endtikzpicture
      enddocument



      Screenshot of the result:



      Screenshot of the result




      Description of the issue:



      As you can see,



      • the border does not fit with the outer dimension of the legend items,

      • the legend items are not precisely aligned below each other.

      So my questions are: How to solve this and make it look nice?










      share|improve this question
















      The user marmot has posted a really nice approach of adding legend items into one single box below a multigraph diagram by placing them inside a node.



      Based on this initial situation I have tried to separate the legend items into three rows above each other, but the result is missleading.




      Minimum Working Example (MWE):



      documentclass[border=5mm]standalone
      usepackagepgfplots
      usetikzlibrarypositioning
      pgfplotssetcompat=newest, scale only axis
      begindocument

      begintikzpicture
      beginscope[local bounding box=plots]
      beginaxis[
      axis y line* = left,
      legend to name = legA,
      legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      /tikz/every odd column/.append style = column sep=0.15cm,
      ,
      ]%
      addplot coordinates (0,0) (1,1);
      addplot coordinates (1,0) (0,1);
      addplot coordinates (0,1) (1,1);
      legendGraph 1, Graph 2, Graph 3;
      endaxis%
      %
      beginaxis[
      axis x line = none,
      axis y line* = right,
      legend to name = legB,
      legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      /tikz/every odd column/.append style = column sep=0.15cm,
      ,
      ]%
      addplot coordinates (0,1) (1,0);
      addplot coordinates (0,0.5) (1,0.5);
      addplot coordinates (0,0.15) (1,0.15);
      legendGraphinggraph 4, Graphinggraph 5, Graphinggraph 6;
      endaxis%
      %
      beginaxis[
      axis x line = none,
      axis y line* = right,
      legend to name = legC,
      legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      /tikz/every odd column/.append style = column sep=0.15cm,
      ,
      ]%
      pgfplotsset%
      %
      every outer y axis line/.style = xshift=2cm,
      every tick/.style = xshift=2cm,
      every y tick label/.style = xshift=2cm,
      %
      addplot coordinates (0.5,0) (0.5,1);
      addplot coordinates (0.6,0) (0.6,1);
      addplot coordinates (0.7,0) (0.7,1);
      legendGraphgraph 7, Graphgraph 8, Graphgraph 9;
      endaxis%
      endscope
      node[below=3.5em of plots.south] (legA) reflegA;
      node[below=-0.5em of legA] (legB) reflegB;
      node[below=-0.5em of legB] (legC) reflegC;
      draw (legA.north west) rectangle (legC.south east);
      endtikzpicture
      enddocument



      Screenshot of the result:



      Screenshot of the result




      Description of the issue:



      As you can see,



      • the border does not fit with the outer dimension of the legend items,

      • the legend items are not precisely aligned below each other.

      So my questions are: How to solve this and make it look nice?







      tikz-pgf pgfplots positioning legend tikz-graphdrawing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 5 mins ago









      KJO

      3,2171221




      3,2171221










      asked 7 hours ago









      DaveDave

      893619




      893619




















          1 Answer
          1






          active

          oldest

          votes


















          0














          I will try to answer just your WHY

          before @marmot awakes and sees me messing about with TikZ / pgfplots answers.



          His answer was provided by the first poster (thus not strctly marmots choice) it depended on an automatic box that adjusts width so unless the text in each column is equal the legend will be unequal.



          You could cheat by adding spaces to match the longest entry as I have done here
          enter image description here



          to save space I will only add the changed lines



           legendGrumpy children whine ~ ~ ~1, Graph with fixed width 2, Graph with fixed width 3;
          legendGrapes make good wine ~ ~ ~4, Graph with fixed width 5, Graph with fixed width 6;
          legendGraph with fixed width~ ~ ~7, Graph with fixed width 8, Graph~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~9;


          This how to "fix" it is far from ideal, and a different answer is needed for how to replace it. so lets see if a question flag change will get you a real answer






          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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            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%2f480547%2fpgfplots-how-to-control-and-align-legend-items-precisely-above-each-other%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I will try to answer just your WHY

            before @marmot awakes and sees me messing about with TikZ / pgfplots answers.



            His answer was provided by the first poster (thus not strctly marmots choice) it depended on an automatic box that adjusts width so unless the text in each column is equal the legend will be unequal.



            You could cheat by adding spaces to match the longest entry as I have done here
            enter image description here



            to save space I will only add the changed lines



             legendGrumpy children whine ~ ~ ~1, Graph with fixed width 2, Graph with fixed width 3;
            legendGrapes make good wine ~ ~ ~4, Graph with fixed width 5, Graph with fixed width 6;
            legendGraph with fixed width~ ~ ~7, Graph with fixed width 8, Graph~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~9;


            This how to "fix" it is far from ideal, and a different answer is needed for how to replace it. so lets see if a question flag change will get you a real answer






            share|improve this answer



























              0














              I will try to answer just your WHY

              before @marmot awakes and sees me messing about with TikZ / pgfplots answers.



              His answer was provided by the first poster (thus not strctly marmots choice) it depended on an automatic box that adjusts width so unless the text in each column is equal the legend will be unequal.



              You could cheat by adding spaces to match the longest entry as I have done here
              enter image description here



              to save space I will only add the changed lines



               legendGrumpy children whine ~ ~ ~1, Graph with fixed width 2, Graph with fixed width 3;
              legendGrapes make good wine ~ ~ ~4, Graph with fixed width 5, Graph with fixed width 6;
              legendGraph with fixed width~ ~ ~7, Graph with fixed width 8, Graph~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~9;


              This how to "fix" it is far from ideal, and a different answer is needed for how to replace it. so lets see if a question flag change will get you a real answer






              share|improve this answer

























                0












                0








                0







                I will try to answer just your WHY

                before @marmot awakes and sees me messing about with TikZ / pgfplots answers.



                His answer was provided by the first poster (thus not strctly marmots choice) it depended on an automatic box that adjusts width so unless the text in each column is equal the legend will be unequal.



                You could cheat by adding spaces to match the longest entry as I have done here
                enter image description here



                to save space I will only add the changed lines



                 legendGrumpy children whine ~ ~ ~1, Graph with fixed width 2, Graph with fixed width 3;
                legendGrapes make good wine ~ ~ ~4, Graph with fixed width 5, Graph with fixed width 6;
                legendGraph with fixed width~ ~ ~7, Graph with fixed width 8, Graph~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~9;


                This how to "fix" it is far from ideal, and a different answer is needed for how to replace it. so lets see if a question flag change will get you a real answer






                share|improve this answer













                I will try to answer just your WHY

                before @marmot awakes and sees me messing about with TikZ / pgfplots answers.



                His answer was provided by the first poster (thus not strctly marmots choice) it depended on an automatic box that adjusts width so unless the text in each column is equal the legend will be unequal.



                You could cheat by adding spaces to match the longest entry as I have done here
                enter image description here



                to save space I will only add the changed lines



                 legendGrumpy children whine ~ ~ ~1, Graph with fixed width 2, Graph with fixed width 3;
                legendGrapes make good wine ~ ~ ~4, Graph with fixed width 5, Graph with fixed width 6;
                legendGraph with fixed width~ ~ ~7, Graph with fixed width 8, Graph~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~9;


                This how to "fix" it is far from ideal, and a different answer is needed for how to replace it. so lets see if a question flag change will get you a real answer







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 10 mins ago









                KJOKJO

                3,2171221




                3,2171221



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480547%2fpgfplots-how-to-control-and-align-legend-items-precisely-above-each-other%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How should I use the fbox command correctly to avoid producing a Bad Box message?How to put a long piece of text in a box?How to specify height and width of fboxIs there an arrayrulecolor-like command to change the rule color of fbox?What is the command to highlight bad boxes in pdf?Why does fbox sometimes place the box *over* the graphic image?how to put the text in the boxHow to create command for a box where text inside the box can automatically adjust?how can I make an fbox like command with certain color, shape and width of border?how to use fbox in align modeFbox increase the spacing between the box and it content (inner margin)how to change the box height of an equationWhat is the use of the hbox in a newcommand command?

                    Doxepinum Nexus interni Notae | Tabula navigationis3158DB01142WHOa682390"Structural Analysis of the Histamine H1 Receptor""Transdermal and Topical Drug Administration in the Treatment of Pain""Antidepressants as antipruritic agents: A review"

                    inputenc: Unicode character … not set up for use with LaTeX The Next CEO of Stack OverflowEntering Unicode characters in LaTeXHow to solve the `Package inputenc Error: Unicode char not set up for use with LaTeX` problem?solve “Unicode char is not set up for use with LaTeX” without special handling of every new interesting UTF-8 characterPackage inputenc Error: Unicode character ² (U+B2)(inputenc) not set up for use with LaTeX. acroI2C[I²C]package inputenc error unicode char (u + 190) not set up for use with latexPackage inputenc Error: Unicode char u8:′ not set up for use with LaTeX. 3′inputenc Error: Unicode char u8: not set up for use with LaTeX with G-BriefPackage Inputenc Error: Unicode char u8: not set up for use with LaTeXPackage inputenc Error: Unicode char ́ (U+301)(inputenc) not set up for use with LaTeX. includePackage inputenc Error: Unicode char ̂ (U+302)(inputenc) not set up for use with LaTeX. … $widehatleft (OA,AA' right )$Package inputenc Error: Unicode char â„¡ (U+2121)(inputenc) not set up for use with LaTeX. printbibliography[heading=bibintoc]Package inputenc Error: Unicode char − (U+2212)(inputenc) not set up for use with LaTeXPackage inputenc Error: Unicode character α (U+3B1) not set up for use with LaTeXPackage inputenc Error: Unicode characterError: ! Package inputenc Error: Unicode char ⊘ (U+2298)(inputenc) not set up for use with LaTeX