pgfplots: How to align legend to same width as plot?pgfplots: How to control and align legend items precisely above each other?plotting two time series with boundsGrouped bar chartHow do i get the x axis on top but keep a line on the bottomHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?How to increase legend lines lengths in PGFplotsHow to hide empty (value 0) ybars with pgfplots?Show mark labels near marks and not centered in ybar interaval graphLine up nested tikz enviroments or how to get rid of thempgfplots: percentage in matrix plotCenter the axes in the coordinate origin

Open a doc from terminal, but not by its name

Why does a simple loop result in ASYNC_NETWORK_IO waits?

This is why we puzzle

How do you make your own symbol when Detexify fails?

Which was the first story featuring espers?

Why should universal income be universal?

Shouldn’t conservatives embrace universal basic income?

Is there a nicer/politer/more positive alternative for "negates"?

Multiplicative persistence

Is this toilet slogan correct usage of the English language?

Giving feedback to someone without sounding prejudiced

Do we have to expect a queue for the shuttle from Watford Junction to Harry Potter Studio?

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

What (the heck) is a Super Worm Equinox Moon?

awk assign to multiple variables at once

How to create a paid keyvalue store

What to do when eye contact makes your coworker uncomfortable?

It grows, but water kills it

What is going on with gets(stdin) on the site coderbyte?

15% tax on $7.5k earnings. Is that right?

Does the Linux kernel need a file system to run?

Why does int i = 10; i / 0; compile, but 5 / 0 gives CS0020 - Division by constant zero?

What is the duration of the spell Creation when used to create non-precious metals?

How can I write humor as character trait?



pgfplots: How to align legend to same width as plot?


pgfplots: How to control and align legend items precisely above each other?plotting two time series with boundsGrouped bar chartHow do i get the x axis on top but keep a line on the bottomHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?How to increase legend lines lengths in PGFplotsHow to hide empty (value 0) ybars with pgfplots?Show mark labels near marks and not centered in ybar interaval graphLine up nested tikz enviroments or how to get rid of thempgfplots: percentage in matrix plotCenter the axes in the coordinate origin













0















The user marmot has posted a nice approach to put a multigraph legend below a diagram.




Minimum Working Example (MWE):



documentclass[border=5mm]standalone
usepackagepgfplots
usetikzlibrarypositioning
pgfplotssetcompat=newest, scale only axis
begindocument
pgfplotssetsuperb legend/.style=legend style = draw=none,
legend columns = 3,
/tikz/every even column/.append style = column sep=0.5cm,
text width=7em,
/tikz/every odd column/.append style = column sep=0.15cm,
text width=7em,

begintikzpicture
beginscope[local bounding box=plots]
beginaxis[
axis y line* = left,
legend to name = legA,
superb legend
]%
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,
superb legend
]%
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,
superb legend
]%
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:



  • Would it be possible to adjust the width of the plot to the width of the legend box (see upper screenshot with red markings)?

Or, alternatively:



  • Adjust the width of the legend box to the width of the plot?

How can I solve that nicely without playing around with the legend items text width? Maybe we can create some global variable to specify the widths of legend and plot together?









share


























    0















    The user marmot has posted a nice approach to put a multigraph legend below a diagram.




    Minimum Working Example (MWE):



    documentclass[border=5mm]standalone
    usepackagepgfplots
    usetikzlibrarypositioning
    pgfplotssetcompat=newest, scale only axis
    begindocument
    pgfplotssetsuperb legend/.style=legend style = draw=none,
    legend columns = 3,
    /tikz/every even column/.append style = column sep=0.5cm,
    text width=7em,
    /tikz/every odd column/.append style = column sep=0.15cm,
    text width=7em,

    begintikzpicture
    beginscope[local bounding box=plots]
    beginaxis[
    axis y line* = left,
    legend to name = legA,
    superb legend
    ]%
    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,
    superb legend
    ]%
    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,
    superb legend
    ]%
    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:



    • Would it be possible to adjust the width of the plot to the width of the legend box (see upper screenshot with red markings)?

    Or, alternatively:



    • Adjust the width of the legend box to the width of the plot?

    How can I solve that nicely without playing around with the legend items text width? Maybe we can create some global variable to specify the widths of legend and plot together?









    share
























      0












      0








      0








      The user marmot has posted a nice approach to put a multigraph legend below a diagram.




      Minimum Working Example (MWE):



      documentclass[border=5mm]standalone
      usepackagepgfplots
      usetikzlibrarypositioning
      pgfplotssetcompat=newest, scale only axis
      begindocument
      pgfplotssetsuperb legend/.style=legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      text width=7em,
      /tikz/every odd column/.append style = column sep=0.15cm,
      text width=7em,

      begintikzpicture
      beginscope[local bounding box=plots]
      beginaxis[
      axis y line* = left,
      legend to name = legA,
      superb legend
      ]%
      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,
      superb legend
      ]%
      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,
      superb legend
      ]%
      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:



      • Would it be possible to adjust the width of the plot to the width of the legend box (see upper screenshot with red markings)?

      Or, alternatively:



      • Adjust the width of the legend box to the width of the plot?

      How can I solve that nicely without playing around with the legend items text width? Maybe we can create some global variable to specify the widths of legend and plot together?









      share














      The user marmot has posted a nice approach to put a multigraph legend below a diagram.




      Minimum Working Example (MWE):



      documentclass[border=5mm]standalone
      usepackagepgfplots
      usetikzlibrarypositioning
      pgfplotssetcompat=newest, scale only axis
      begindocument
      pgfplotssetsuperb legend/.style=legend style = draw=none,
      legend columns = 3,
      /tikz/every even column/.append style = column sep=0.5cm,
      text width=7em,
      /tikz/every odd column/.append style = column sep=0.15cm,
      text width=7em,

      begintikzpicture
      beginscope[local bounding box=plots]
      beginaxis[
      axis y line* = left,
      legend to name = legA,
      superb legend
      ]%
      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,
      superb legend
      ]%
      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,
      superb legend
      ]%
      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:



      • Would it be possible to adjust the width of the plot to the width of the legend box (see upper screenshot with red markings)?

      Or, alternatively:



      • Adjust the width of the legend box to the width of the plot?

      How can I solve that nicely without playing around with the legend items text width? Maybe we can create some global variable to specify the widths of legend and plot together?







      tikz-pgf pgfplots width legend adjustwidth





      share












      share










      share



      share










      asked 1 min ago









      DaveDave

      905619




      905619




















          0






          active

          oldest

          votes











          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%2f480910%2fpgfplots-how-to-align-legend-to-same-width-as-plot%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f480910%2fpgfplots-how-to-align-legend-to-same-width-as-plot%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

          acmart: Multiple authors: all with same affiliation, one author an additional affiliationHow to Write Names of Multiple Authors with Shared Affiliation in ACM 2017 Template?Multiple authors with different primary affiliation, but same additional affiliationSame affiliation for all authors without extra packagesIOS-Book-Article.cls: one author with multiple affiliationacmart: Shared Author AffiliationMultiple authors with different primary affiliation, but same additional affiliationAuthor affiliation with only 1 authorAdding Multiple Authors with Different Affiliation in LaTeX ArticleLaTeX: Multiple authors stays on same lineHow to Label Multiple Authors with Same DescriptionHow to make two authors use the same affiliationTwo authors with same affiliation on finished front page

          How to write “ä” and other umlauts and accented letters in bibliography?Accents in BibTeXSorting references with special characters alphabeticallyUse ae ligature in bibliographyEastern European nameInverted circumflex in BibTexBibTex, non-ascii initials and nameptr fproblems with accent in LatexHow to add a Ø to my bibliography from Jabref?References without accentsTroubles when trying to cite St“omer-Verlet in ”title" field of a bib entryComprehensive list of accented charactersHow to type the letter “i” with two dots (diaeresis) in math mode?Problem with glossary text and accented lettersSpecial character in bibliographyAccented letters, Unicode and LaTeX accentsHow to stop natbib from modifying bibliography styleCitation of a paper with non-standard characters by BibtexWrite accented characters to file using writeHow to group the bibliography alphabetically, if some surnames start with “accented” characters?How can I automatically capitalize significant words in my bibliography?

          How to remove border form elements in the last row?Targeting flex items on the last rowHow to vertically wrap content with flexbox?Remove border from IFrameCSS3's border-radius property and border-collapse:collapse don't mix. How can I use border-radius to create a collapsed table with rounded corners?Div width 100% minus fixed amount of pixelsBorder around specific rows in a table?How to remove border (outline) around text/input boxes? (Chrome)How do I remove the space between inline-block elements?Flex-box: Align last row to gridRemove blue border from css custom-styled button in ChromeFill remaining vertical space with CSS using display:flexhow style elements in the last row of flexbox row layout with pure css without js