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

Extract all GPU name, model and GPU ram

51k Euros annually for a family of 4 in Berlin: Is it enough?

Identifying polygons that intersect with another layer using QGIS?

How do I keep my slimes from escaping their pens?

List *all* the tuples!

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

Can a non-EU citizen traveling with me come with me through the EU passport line?

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

Echoing a tail command produces unexpected output?

List of Python versions

How to bypass password on Windows XP account?

What does F' and F" mean?

Ring Automorphisms that fix 1.

porting install scripts : can rpm replace apt?

Can an alien society believe that their star system is the universe?

If a contract sometimes uses the wrong name, is it still valid?

What is the meaning of the new sigil in Game of Thrones Season 8 intro?

Apollo command module space walk?

Why did the rest of the Eastern Bloc not invade Yugoslavia?

Why light coming from distant stars is not discrete?

Why didn't this character "real die" when they blew their stack out in Altered Carbon?

How come Sam didn't become Lord of Horn Hill?

How to call a function with default parameter through a pointer to function that is the return of another function?

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



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 5 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

          Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

          Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

          How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...