Adding legend entry for border of fill, from fillbetween











up vote
0
down vote

favorite












I've made a plot like the one below to show a distribution of values in the dependent variable versus the change of the independent variable.



documentclass[varwidth]{standalone}
usepackage{pgfplots}
usepackage{pgfplotstable}
usepgfplotslibrary{fillbetween}
usepackage{tikz}

pgfplotstableread{
x min q1 med q3 max
1 0 2 4 6 8
2 2 4 5 6 8
3 1 3 5 7 9
}data%

begin{document}
begin{tikzpicture}
begin{axis}[title=Example,
xlabel=x,
ylabel=y,
]
addplot[blue, dashed] table [x=x, y=min] {data};
addplot[blue, dotted, name path global=q1] table [x=x, y=q1] {data};
addplot[blue, solid] table [x=x, y=med] {data};
addplot[blue, dotted, name path global=q3] table [x=x, y=q3] {data};
addplot[blue, dashed] table [x=x, y=max] {data};
addplot[blue, fill opacity=0.3] fill between[of=q1 and q3];
end{axis}
end{tikzpicture}

end{document}


Image showing resulting PDF plot from code, above



I'd like to have a legend like the following,



Example legend



Is that possible? How?









share


























    up vote
    0
    down vote

    favorite












    I've made a plot like the one below to show a distribution of values in the dependent variable versus the change of the independent variable.



    documentclass[varwidth]{standalone}
    usepackage{pgfplots}
    usepackage{pgfplotstable}
    usepgfplotslibrary{fillbetween}
    usepackage{tikz}

    pgfplotstableread{
    x min q1 med q3 max
    1 0 2 4 6 8
    2 2 4 5 6 8
    3 1 3 5 7 9
    }data%

    begin{document}
    begin{tikzpicture}
    begin{axis}[title=Example,
    xlabel=x,
    ylabel=y,
    ]
    addplot[blue, dashed] table [x=x, y=min] {data};
    addplot[blue, dotted, name path global=q1] table [x=x, y=q1] {data};
    addplot[blue, solid] table [x=x, y=med] {data};
    addplot[blue, dotted, name path global=q3] table [x=x, y=q3] {data};
    addplot[blue, dashed] table [x=x, y=max] {data};
    addplot[blue, fill opacity=0.3] fill between[of=q1 and q3];
    end{axis}
    end{tikzpicture}

    end{document}


    Image showing resulting PDF plot from code, above



    I'd like to have a legend like the following,



    Example legend



    Is that possible? How?









    share
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I've made a plot like the one below to show a distribution of values in the dependent variable versus the change of the independent variable.



      documentclass[varwidth]{standalone}
      usepackage{pgfplots}
      usepackage{pgfplotstable}
      usepgfplotslibrary{fillbetween}
      usepackage{tikz}

      pgfplotstableread{
      x min q1 med q3 max
      1 0 2 4 6 8
      2 2 4 5 6 8
      3 1 3 5 7 9
      }data%

      begin{document}
      begin{tikzpicture}
      begin{axis}[title=Example,
      xlabel=x,
      ylabel=y,
      ]
      addplot[blue, dashed] table [x=x, y=min] {data};
      addplot[blue, dotted, name path global=q1] table [x=x, y=q1] {data};
      addplot[blue, solid] table [x=x, y=med] {data};
      addplot[blue, dotted, name path global=q3] table [x=x, y=q3] {data};
      addplot[blue, dashed] table [x=x, y=max] {data};
      addplot[blue, fill opacity=0.3] fill between[of=q1 and q3];
      end{axis}
      end{tikzpicture}

      end{document}


      Image showing resulting PDF plot from code, above



      I'd like to have a legend like the following,



      Example legend



      Is that possible? How?









      share













      I've made a plot like the one below to show a distribution of values in the dependent variable versus the change of the independent variable.



      documentclass[varwidth]{standalone}
      usepackage{pgfplots}
      usepackage{pgfplotstable}
      usepgfplotslibrary{fillbetween}
      usepackage{tikz}

      pgfplotstableread{
      x min q1 med q3 max
      1 0 2 4 6 8
      2 2 4 5 6 8
      3 1 3 5 7 9
      }data%

      begin{document}
      begin{tikzpicture}
      begin{axis}[title=Example,
      xlabel=x,
      ylabel=y,
      ]
      addplot[blue, dashed] table [x=x, y=min] {data};
      addplot[blue, dotted, name path global=q1] table [x=x, y=q1] {data};
      addplot[blue, solid] table [x=x, y=med] {data};
      addplot[blue, dotted, name path global=q3] table [x=x, y=q3] {data};
      addplot[blue, dashed] table [x=x, y=max] {data};
      addplot[blue, fill opacity=0.3] fill between[of=q1 and q3];
      end{axis}
      end{tikzpicture}

      end{document}


      Image showing resulting PDF plot from code, above



      I'd like to have a legend like the following,



      Example legend



      Is that possible? How?







      pgfplots legend fillbetween





      share












      share










      share



      share










      asked 2 mins ago









      john_stech

      82




      82



























          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',
          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%2f461654%2fadding-legend-entry-for-border-of-fill-from-fillbetween%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461654%2fadding-legend-entry-for-border-of-fill-from-fillbetween%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

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)