Adding points and their relative legend with tikz












1















The following code



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}


produces the picture below:



enter image description here



In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:



enter image description here



EDIT



However, the code:



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}


does not solve my problem:



enter image description here










share|improve this question

























  • How about invoking the respective addlegendentry only once instead of twice?

    – marmot
    7 hours ago











  • I've edited my post. Unfortunately I have another issue.

    – Mark
    6 hours ago
















1















The following code



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}


produces the picture below:



enter image description here



In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:



enter image description here



EDIT



However, the code:



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}


does not solve my problem:



enter image description here










share|improve this question

























  • How about invoking the respective addlegendentry only once instead of twice?

    – marmot
    7 hours ago











  • I've edited my post. Unfortunately I have another issue.

    – Mark
    6 hours ago














1












1








1








The following code



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}


produces the picture below:



enter image description here



In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:



enter image description here



EDIT



However, the code:



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}


does not solve my problem:



enter image description here










share|improve this question
















The following code



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}


produces the picture below:



enter image description here



In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:



enter image description here



EDIT



However, the code:



begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}


does not solve my problem:



enter image description here







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 6 hours ago







Mark

















asked 7 hours ago









MarkMark

23716




23716













  • How about invoking the respective addlegendentry only once instead of twice?

    – marmot
    7 hours ago











  • I've edited my post. Unfortunately I have another issue.

    – Mark
    6 hours ago



















  • How about invoking the respective addlegendentry only once instead of twice?

    – marmot
    7 hours ago











  • I've edited my post. Unfortunately I have another issue.

    – Mark
    6 hours ago

















How about invoking the respective addlegendentry only once instead of twice?

– marmot
7 hours ago





How about invoking the respective addlegendentry only once instead of twice?

– marmot
7 hours ago













I've edited my post. Unfortunately I have another issue.

– Mark
6 hours ago





I've edited my post. Unfortunately I have another issue.

– Mark
6 hours ago










1 Answer
1






active

oldest

votes


















2














One should never forget about the option forget plot, which allows you to disregard a plot for a legend. I added this to every other plot to obtain



documentclass[border=3.14mm,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x,forget plot] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o,forget plot] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square,forget plot] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
end{document}


enter image description here






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%2f482825%2fadding-points-and-their-relative-legend-with-tikz%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









    2














    One should never forget about the option forget plot, which allows you to disregard a plot for a legend. I added this to every other plot to obtain



    documentclass[border=3.14mm,tikz]{standalone}
    usepackage{pgfplots}
    pgfplotsset{compat=1.16}
    begin{document}
    begin{tikzpicture}
    begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
    addlegendimage{empty legend}
    addlegendentry{}
    addplot+[smooth,draw=black,mark=oplus] coordinates
    {(0.3,0.275)};
    addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
    {(0.2,0.15)};
    addlegendentry{$zeta=10$}
    addplot+[smooth,draw=black,mark=x] coordinates
    {(0.345743, 0.332178)};
    addplot+[smooth,draw=black,mark=x,forget plot] coordinates
    {(0.154257, 0.0928216)};
    addlegendentry{$zeta=15$}
    addplot+[smooth,draw=black,mark=o] coordinates
    {(0.361803,0.352254)};
    addplot+[smooth,draw=black,mark=o,forget plot] coordinates
    {(0.138197, 0.0727458)};
    addlegendentry{$zeta=20$}
    addplot+[smooth,draw=black,mark=square] coordinates
    {(0.370416, 0.36302)};
    addplot+[smooth,draw=black,mark=square,forget plot] coordinates
    {(0.129584, 0.0619801)};
    addlegendentry{$zeta=25$}
    end{axis}
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer




























      2














      One should never forget about the option forget plot, which allows you to disregard a plot for a legend. I added this to every other plot to obtain



      documentclass[border=3.14mm,tikz]{standalone}
      usepackage{pgfplots}
      pgfplotsset{compat=1.16}
      begin{document}
      begin{tikzpicture}
      begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
      addlegendimage{empty legend}
      addlegendentry{}
      addplot+[smooth,draw=black,mark=oplus] coordinates
      {(0.3,0.275)};
      addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
      {(0.2,0.15)};
      addlegendentry{$zeta=10$}
      addplot+[smooth,draw=black,mark=x] coordinates
      {(0.345743, 0.332178)};
      addplot+[smooth,draw=black,mark=x,forget plot] coordinates
      {(0.154257, 0.0928216)};
      addlegendentry{$zeta=15$}
      addplot+[smooth,draw=black,mark=o] coordinates
      {(0.361803,0.352254)};
      addplot+[smooth,draw=black,mark=o,forget plot] coordinates
      {(0.138197, 0.0727458)};
      addlegendentry{$zeta=20$}
      addplot+[smooth,draw=black,mark=square] coordinates
      {(0.370416, 0.36302)};
      addplot+[smooth,draw=black,mark=square,forget plot] coordinates
      {(0.129584, 0.0619801)};
      addlegendentry{$zeta=25$}
      end{axis}
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer


























        2












        2








        2







        One should never forget about the option forget plot, which allows you to disregard a plot for a legend. I added this to every other plot to obtain



        documentclass[border=3.14mm,tikz]{standalone}
        usepackage{pgfplots}
        pgfplotsset{compat=1.16}
        begin{document}
        begin{tikzpicture}
        begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
        addlegendimage{empty legend}
        addlegendentry{}
        addplot+[smooth,draw=black,mark=oplus] coordinates
        {(0.3,0.275)};
        addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
        {(0.2,0.15)};
        addlegendentry{$zeta=10$}
        addplot+[smooth,draw=black,mark=x] coordinates
        {(0.345743, 0.332178)};
        addplot+[smooth,draw=black,mark=x,forget plot] coordinates
        {(0.154257, 0.0928216)};
        addlegendentry{$zeta=15$}
        addplot+[smooth,draw=black,mark=o] coordinates
        {(0.361803,0.352254)};
        addplot+[smooth,draw=black,mark=o,forget plot] coordinates
        {(0.138197, 0.0727458)};
        addlegendentry{$zeta=20$}
        addplot+[smooth,draw=black,mark=square] coordinates
        {(0.370416, 0.36302)};
        addplot+[smooth,draw=black,mark=square,forget plot] coordinates
        {(0.129584, 0.0619801)};
        addlegendentry{$zeta=25$}
        end{axis}
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer













        One should never forget about the option forget plot, which allows you to disregard a plot for a legend. I added this to every other plot to obtain



        documentclass[border=3.14mm,tikz]{standalone}
        usepackage{pgfplots}
        pgfplotsset{compat=1.16}
        begin{document}
        begin{tikzpicture}
        begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
        addlegendimage{empty legend}
        addlegendentry{}
        addplot+[smooth,draw=black,mark=oplus] coordinates
        {(0.3,0.275)};
        addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
        {(0.2,0.15)};
        addlegendentry{$zeta=10$}
        addplot+[smooth,draw=black,mark=x] coordinates
        {(0.345743, 0.332178)};
        addplot+[smooth,draw=black,mark=x,forget plot] coordinates
        {(0.154257, 0.0928216)};
        addlegendentry{$zeta=15$}
        addplot+[smooth,draw=black,mark=o] coordinates
        {(0.361803,0.352254)};
        addplot+[smooth,draw=black,mark=o,forget plot] coordinates
        {(0.138197, 0.0727458)};
        addlegendentry{$zeta=20$}
        addplot+[smooth,draw=black,mark=square] coordinates
        {(0.370416, 0.36302)};
        addplot+[smooth,draw=black,mark=square,forget plot] coordinates
        {(0.129584, 0.0619801)};
        addlegendentry{$zeta=25$}
        end{axis}
        end{tikzpicture}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 5 hours ago









        marmotmarmot

        114k5145276




        114k5145276






























            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%2f482825%2fadding-points-and-their-relative-legend-with-tikz%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

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

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