How to add two separate legends for two axes? Announcing the arrival of Valued Associate #679:...

Apollo command module space walk?

Why aren't air breathing engines used as small first stages

Why are Kinder Surprise Eggs illegal in the USA?

How do I name drop voicings

Short Story with Cinderella as a Voo-doo Witch

ListPlot join points by nearest neighbor rather than order

Output the ŋarâþ crîþ alphabet song without using (m)any letters

Identifying polygons that intersect with another layer using QGIS?

How can I make names more distinctive without making them longer?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

When do you get frequent flier miles - when you buy, or when you fly?

What does the "x" in "x86" represent?

Generate an RGB colour grid

How do I stop a creek from eroding my steep embankment?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Sci-Fi book where patients in a coma ward all live in a subconscious world linked together

How much time will it take to get my passport back if I am applying for multiple Schengen visa countries?

How discoverable are IPv6 addresses and AAAA names by potential attackers?

English words in a non-english sci-fi novel

Why did the IBM 650 use bi-quinary?

What's the meaning of 間時肆拾貳 at a car parking sign

What does this icon in iOS Stardew Valley mean?

Why did the Falcon Heavy center core fall off the ASDS OCISLY barge?

How widely used is the term Treppenwitz? Is it something that most Germans know?



How to add two separate legends for two axes?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How can I use two x axes in pgfplots?Grouped bar chartLegends for scaled pgfplotsSpecifying different scales for the axespgfplots ignores “thick” option for axesexample: pgfplots groupplot with two x-axesHow to add multiple x axes with different scaling?How to add two waveforms in pgfplotsCenter the axes in the coordinate originHow to add two tables with PGFPlots?












0















I want to add two separate legends for two axes as the picture shows ().



However, my situation is a little more complicated. I have three entries that need to be labeled in the two legends -- one for the left axis and the other two for the right axis. Meanwhile, one of them has lines as background which should also be depicted in the (right) legend.



How to create such two separate legends. Specifically, the left legend is a blue rectangle followed by some words while the right legend contains two lines -- one is a red rectangle and the other is a red rectangle with dashed lines followed by some words.



usepackage{pgfplots}
pgfplotsset{compat=1.14}
usepackage{tikz}
usetikzlibrary{patterns}

begin{figure}[tb]
centering
hspace*{-0.2cm}
begin{tikzpicture}[font=footnotesize]
begin{axis}[ybar stacked,
height=4.5cm,width=9cm,
ymin=0,ymax=6,
bar shift=-5.5pt,
symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-\item List},
x tick label style={align=center,font=scriptsize},
axis y line*=left,
/pgf/bar width=7pt,
]
addplot coordinates
{(Launch,4.25) (Options,4.5) (Text Input,3.25) (Text\Display,4) (Fixed-item\List,4.33) (Dynamic-\item List,5.25)};
end{axis}

begin{axis}[ybar stacked,
height=4.5cm,width=9cm,
ymin=0,ymax=25,
bar shift=5.5pt,
symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-item\List},
xtick=empty,
axis y line*=right,
/pgf/bar width=7pt,
]
addplot +[
draw=red,fill=red!30!white,
postaction={pattern=north east lines}
] coordinates
{(Launch,4) (Options,5.5) (Text Input,3.75) (Text\Display,4) (Fixed-item\List,7.77) (Dynamic-item\List,4.5)};
addplot +[draw=red,fill=red!30!white] coordinates
{(Launch,9) (Options,6) (Text Input,8) (Text\Display,6.5) (Fixed-item\List,14.55) (Dynamic-item\List,5)};
end{axis}
end{tikzpicture}
end{figure}


The desired visual effect



My figure









share







New contributor




Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I want to add two separate legends for two axes as the picture shows ().



    However, my situation is a little more complicated. I have three entries that need to be labeled in the two legends -- one for the left axis and the other two for the right axis. Meanwhile, one of them has lines as background which should also be depicted in the (right) legend.



    How to create such two separate legends. Specifically, the left legend is a blue rectangle followed by some words while the right legend contains two lines -- one is a red rectangle and the other is a red rectangle with dashed lines followed by some words.



    usepackage{pgfplots}
    pgfplotsset{compat=1.14}
    usepackage{tikz}
    usetikzlibrary{patterns}

    begin{figure}[tb]
    centering
    hspace*{-0.2cm}
    begin{tikzpicture}[font=footnotesize]
    begin{axis}[ybar stacked,
    height=4.5cm,width=9cm,
    ymin=0,ymax=6,
    bar shift=-5.5pt,
    symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-\item List},
    x tick label style={align=center,font=scriptsize},
    axis y line*=left,
    /pgf/bar width=7pt,
    ]
    addplot coordinates
    {(Launch,4.25) (Options,4.5) (Text Input,3.25) (Text\Display,4) (Fixed-item\List,4.33) (Dynamic-\item List,5.25)};
    end{axis}

    begin{axis}[ybar stacked,
    height=4.5cm,width=9cm,
    ymin=0,ymax=25,
    bar shift=5.5pt,
    symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-item\List},
    xtick=empty,
    axis y line*=right,
    /pgf/bar width=7pt,
    ]
    addplot +[
    draw=red,fill=red!30!white,
    postaction={pattern=north east lines}
    ] coordinates
    {(Launch,4) (Options,5.5) (Text Input,3.75) (Text\Display,4) (Fixed-item\List,7.77) (Dynamic-item\List,4.5)};
    addplot +[draw=red,fill=red!30!white] coordinates
    {(Launch,9) (Options,6) (Text Input,8) (Text\Display,6.5) (Fixed-item\List,14.55) (Dynamic-item\List,5)};
    end{axis}
    end{tikzpicture}
    end{figure}


    The desired visual effect



    My figure









    share







    New contributor




    Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I want to add two separate legends for two axes as the picture shows ().



      However, my situation is a little more complicated. I have three entries that need to be labeled in the two legends -- one for the left axis and the other two for the right axis. Meanwhile, one of them has lines as background which should also be depicted in the (right) legend.



      How to create such two separate legends. Specifically, the left legend is a blue rectangle followed by some words while the right legend contains two lines -- one is a red rectangle and the other is a red rectangle with dashed lines followed by some words.



      usepackage{pgfplots}
      pgfplotsset{compat=1.14}
      usepackage{tikz}
      usetikzlibrary{patterns}

      begin{figure}[tb]
      centering
      hspace*{-0.2cm}
      begin{tikzpicture}[font=footnotesize]
      begin{axis}[ybar stacked,
      height=4.5cm,width=9cm,
      ymin=0,ymax=6,
      bar shift=-5.5pt,
      symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-\item List},
      x tick label style={align=center,font=scriptsize},
      axis y line*=left,
      /pgf/bar width=7pt,
      ]
      addplot coordinates
      {(Launch,4.25) (Options,4.5) (Text Input,3.25) (Text\Display,4) (Fixed-item\List,4.33) (Dynamic-\item List,5.25)};
      end{axis}

      begin{axis}[ybar stacked,
      height=4.5cm,width=9cm,
      ymin=0,ymax=25,
      bar shift=5.5pt,
      symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-item\List},
      xtick=empty,
      axis y line*=right,
      /pgf/bar width=7pt,
      ]
      addplot +[
      draw=red,fill=red!30!white,
      postaction={pattern=north east lines}
      ] coordinates
      {(Launch,4) (Options,5.5) (Text Input,3.75) (Text\Display,4) (Fixed-item\List,7.77) (Dynamic-item\List,4.5)};
      addplot +[draw=red,fill=red!30!white] coordinates
      {(Launch,9) (Options,6) (Text Input,8) (Text\Display,6.5) (Fixed-item\List,14.55) (Dynamic-item\List,5)};
      end{axis}
      end{tikzpicture}
      end{figure}


      The desired visual effect



      My figure









      share







      New contributor




      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I want to add two separate legends for two axes as the picture shows ().



      However, my situation is a little more complicated. I have three entries that need to be labeled in the two legends -- one for the left axis and the other two for the right axis. Meanwhile, one of them has lines as background which should also be depicted in the (right) legend.



      How to create such two separate legends. Specifically, the left legend is a blue rectangle followed by some words while the right legend contains two lines -- one is a red rectangle and the other is a red rectangle with dashed lines followed by some words.



      usepackage{pgfplots}
      pgfplotsset{compat=1.14}
      usepackage{tikz}
      usetikzlibrary{patterns}

      begin{figure}[tb]
      centering
      hspace*{-0.2cm}
      begin{tikzpicture}[font=footnotesize]
      begin{axis}[ybar stacked,
      height=4.5cm,width=9cm,
      ymin=0,ymax=6,
      bar shift=-5.5pt,
      symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-\item List},
      x tick label style={align=center,font=scriptsize},
      axis y line*=left,
      /pgf/bar width=7pt,
      ]
      addplot coordinates
      {(Launch,4.25) (Options,4.5) (Text Input,3.25) (Text\Display,4) (Fixed-item\List,4.33) (Dynamic-\item List,5.25)};
      end{axis}

      begin{axis}[ybar stacked,
      height=4.5cm,width=9cm,
      ymin=0,ymax=25,
      bar shift=5.5pt,
      symbolic x coords={Launch,Options,Text Input,Text\Display,Fixed-item\List,Dynamic-item\List},
      xtick=empty,
      axis y line*=right,
      /pgf/bar width=7pt,
      ]
      addplot +[
      draw=red,fill=red!30!white,
      postaction={pattern=north east lines}
      ] coordinates
      {(Launch,4) (Options,5.5) (Text Input,3.75) (Text\Display,4) (Fixed-item\List,7.77) (Dynamic-item\List,4.5)};
      addplot +[draw=red,fill=red!30!white] coordinates
      {(Launch,9) (Options,6) (Text Input,8) (Text\Display,6.5) (Fixed-item\List,14.55) (Dynamic-item\List,5)};
      end{axis}
      end{tikzpicture}
      end{figure}


      The desired visual effect



      My figure







      pgfplots





      share







      New contributor




      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 mins ago









      Sheffiled GESheffiled GE

      12




      12




      New contributor




      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Sheffiled GE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          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
          });


          }
          });






          Sheffiled GE is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485232%2fhow-to-add-two-separate-legends-for-two-axes%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








          Sheffiled GE is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Sheffiled GE is a new contributor. Be nice, and check out our Code of Conduct.













          Sheffiled GE is a new contributor. Be nice, and check out our Code of Conduct.












          Sheffiled GE is a new contributor. Be nice, and check out our Code of Conduct.
















          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%2f485232%2fhow-to-add-two-separate-legends-for-two-axes%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

          Why does my Macbook overheat and use so much CPU and energy when on YouTube?Why do so many insist on using...

          How to prevent page numbers from appearing on glossaries?How to remove a dot and a page number in the...

          Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...