Dynamically hide and show Plots












1















I would like to know if it's possible to do something like this, using axis in tikzpicture:



enter image description here



I'm currently ploting curves this way :



documentclass{article}

usepackage[latin1]{inputenc}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage{pgf,tikz}
usetikzlibrary{fit}
usetikzlibrary{arrows,patterns}
usepackage{amsmath,siunitx,xcolor}
usepackage{pgfplotstable,pgfplots,filecontents}
pgfplotsset{compat=1.6} %Update pgfplots package version.
usepackage{lscape,rotating,pdflscape}

begin{document}

begin{landscape}
begin{tikzpicture}
begin{axis}[
width=22cm,height=12cm,
legend columns=1,grid=both, legend cell align={left},
ymin=-4,ymax=4,xmin=0,xmax=4,
xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
]
addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
addlegendentry{Wave1}
addlegendentry{Wave2}
end{axis}
end{tikzpicture}
end{landscape}

end{document}









share|improve this question

























  • @JouleV Sadly nothing, I would like some help to start working on this (maybe a specific package or something else).

    – joseldsm
    12 hours ago






  • 1





    As you can see: I misunderstood your question. Please explain your question furthuer, and maybe a sketch of what you want to achieve.

    – JouleV
    12 hours ago






  • 3





    I am not sure that's possible without having a multipage pdf with all possible combinations of on and off. With a multipage pdf it is certainly possible, this is how the beamer buttons work. And sorry, your example is not particular useful. Apart from missing the preamble and end{document} you are loading data that no one has (in order to plot seemingly straight lines...).

    – marmot
    11 hours ago








  • 1





    @marmot, exactly what I am doing, but with i,j,k... :-)

    – Sigur
    11 hours ago






  • 1





    @marmot, oh, just now I saw that OP didn't provide the csv data.

    – Sigur
    11 hours ago
















1















I would like to know if it's possible to do something like this, using axis in tikzpicture:



enter image description here



I'm currently ploting curves this way :



documentclass{article}

usepackage[latin1]{inputenc}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage{pgf,tikz}
usetikzlibrary{fit}
usetikzlibrary{arrows,patterns}
usepackage{amsmath,siunitx,xcolor}
usepackage{pgfplotstable,pgfplots,filecontents}
pgfplotsset{compat=1.6} %Update pgfplots package version.
usepackage{lscape,rotating,pdflscape}

begin{document}

begin{landscape}
begin{tikzpicture}
begin{axis}[
width=22cm,height=12cm,
legend columns=1,grid=both, legend cell align={left},
ymin=-4,ymax=4,xmin=0,xmax=4,
xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
]
addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
addlegendentry{Wave1}
addlegendentry{Wave2}
end{axis}
end{tikzpicture}
end{landscape}

end{document}









share|improve this question

























  • @JouleV Sadly nothing, I would like some help to start working on this (maybe a specific package or something else).

    – joseldsm
    12 hours ago






  • 1





    As you can see: I misunderstood your question. Please explain your question furthuer, and maybe a sketch of what you want to achieve.

    – JouleV
    12 hours ago






  • 3





    I am not sure that's possible without having a multipage pdf with all possible combinations of on and off. With a multipage pdf it is certainly possible, this is how the beamer buttons work. And sorry, your example is not particular useful. Apart from missing the preamble and end{document} you are loading data that no one has (in order to plot seemingly straight lines...).

    – marmot
    11 hours ago








  • 1





    @marmot, exactly what I am doing, but with i,j,k... :-)

    – Sigur
    11 hours ago






  • 1





    @marmot, oh, just now I saw that OP didn't provide the csv data.

    – Sigur
    11 hours ago














1












1








1








I would like to know if it's possible to do something like this, using axis in tikzpicture:



enter image description here



I'm currently ploting curves this way :



documentclass{article}

usepackage[latin1]{inputenc}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage{pgf,tikz}
usetikzlibrary{fit}
usetikzlibrary{arrows,patterns}
usepackage{amsmath,siunitx,xcolor}
usepackage{pgfplotstable,pgfplots,filecontents}
pgfplotsset{compat=1.6} %Update pgfplots package version.
usepackage{lscape,rotating,pdflscape}

begin{document}

begin{landscape}
begin{tikzpicture}
begin{axis}[
width=22cm,height=12cm,
legend columns=1,grid=both, legend cell align={left},
ymin=-4,ymax=4,xmin=0,xmax=4,
xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
]
addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
addlegendentry{Wave1}
addlegendentry{Wave2}
end{axis}
end{tikzpicture}
end{landscape}

end{document}









share|improve this question
















I would like to know if it's possible to do something like this, using axis in tikzpicture:



enter image description here



I'm currently ploting curves this way :



documentclass{article}

usepackage[latin1]{inputenc}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage{pgf,tikz}
usetikzlibrary{fit}
usetikzlibrary{arrows,patterns}
usepackage{amsmath,siunitx,xcolor}
usepackage{pgfplotstable,pgfplots,filecontents}
pgfplotsset{compat=1.6} %Update pgfplots package version.
usepackage{lscape,rotating,pdflscape}

begin{document}

begin{landscape}
begin{tikzpicture}
begin{axis}[
width=22cm,height=12cm,
legend columns=1,grid=both, legend cell align={left},
ymin=-4,ymax=4,xmin=0,xmax=4,
xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
]
addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
addlegendentry{Wave1}
addlegendentry{Wave2}
end{axis}
end{tikzpicture}
end{landscape}

end{document}






tikz-pgf interaction






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 hours ago









AndréC

9,08411447




9,08411447










asked 12 hours ago









joseldsmjoseldsm

837




837













  • @JouleV Sadly nothing, I would like some help to start working on this (maybe a specific package or something else).

    – joseldsm
    12 hours ago






  • 1





    As you can see: I misunderstood your question. Please explain your question furthuer, and maybe a sketch of what you want to achieve.

    – JouleV
    12 hours ago






  • 3





    I am not sure that's possible without having a multipage pdf with all possible combinations of on and off. With a multipage pdf it is certainly possible, this is how the beamer buttons work. And sorry, your example is not particular useful. Apart from missing the preamble and end{document} you are loading data that no one has (in order to plot seemingly straight lines...).

    – marmot
    11 hours ago








  • 1





    @marmot, exactly what I am doing, but with i,j,k... :-)

    – Sigur
    11 hours ago






  • 1





    @marmot, oh, just now I saw that OP didn't provide the csv data.

    – Sigur
    11 hours ago



















  • @JouleV Sadly nothing, I would like some help to start working on this (maybe a specific package or something else).

    – joseldsm
    12 hours ago






  • 1





    As you can see: I misunderstood your question. Please explain your question furthuer, and maybe a sketch of what you want to achieve.

    – JouleV
    12 hours ago






  • 3





    I am not sure that's possible without having a multipage pdf with all possible combinations of on and off. With a multipage pdf it is certainly possible, this is how the beamer buttons work. And sorry, your example is not particular useful. Apart from missing the preamble and end{document} you are loading data that no one has (in order to plot seemingly straight lines...).

    – marmot
    11 hours ago








  • 1





    @marmot, exactly what I am doing, but with i,j,k... :-)

    – Sigur
    11 hours ago






  • 1





    @marmot, oh, just now I saw that OP didn't provide the csv data.

    – Sigur
    11 hours ago

















@JouleV Sadly nothing, I would like some help to start working on this (maybe a specific package or something else).

– joseldsm
12 hours ago





@JouleV Sadly nothing, I would like some help to start working on this (maybe a specific package or something else).

– joseldsm
12 hours ago




1




1





As you can see: I misunderstood your question. Please explain your question furthuer, and maybe a sketch of what you want to achieve.

– JouleV
12 hours ago





As you can see: I misunderstood your question. Please explain your question furthuer, and maybe a sketch of what you want to achieve.

– JouleV
12 hours ago




3




3





I am not sure that's possible without having a multipage pdf with all possible combinations of on and off. With a multipage pdf it is certainly possible, this is how the beamer buttons work. And sorry, your example is not particular useful. Apart from missing the preamble and end{document} you are loading data that no one has (in order to plot seemingly straight lines...).

– marmot
11 hours ago







I am not sure that's possible without having a multipage pdf with all possible combinations of on and off. With a multipage pdf it is certainly possible, this is how the beamer buttons work. And sorry, your example is not particular useful. Apart from missing the preamble and end{document} you are loading data that no one has (in order to plot seemingly straight lines...).

– marmot
11 hours ago






1




1





@marmot, exactly what I am doing, but with i,j,k... :-)

– Sigur
11 hours ago





@marmot, exactly what I am doing, but with i,j,k... :-)

– Sigur
11 hours ago




1




1





@marmot, oh, just now I saw that OP didn't provide the csv data.

– Sigur
11 hours ago





@marmot, oh, just now I saw that OP didn't provide the csv data.

– Sigur
11 hours ago










2 Answers
2






active

oldest

votes


















4














To be compiled twice. Use Adobe Reader, Foxit Reader, (evince ?) or PDF readers that manage OCG layers.



I simply adapted the code of the example given in the ocgx and ocgx2 package.
I'll leave it to you to do the finishing touches.



documentclass{article}

usepackage[latin1]{inputenc}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage{lmodern}
usepackage[top=1.5cm, bottom=4cm, left=2cm, right=2cm]{geometry}
%usepackage{pgf,tikz}
usepackage[tikz]{ocgx2}
usetikzlibrary{backgrounds,calc,shadows,chains,shapes.geometric}
usetikzlibrary{fit}
usetikzlibrary{matrix}
usetikzlibrary{arrows,patterns}
usepackage{amsmath,siunitx,xcolor}
usepackage{pgfplotstable,pgfplots,filecontents}
pgfplotsset{compat=1.6} %Update pgfplots package version.
usepackage{calculator,float}
usepackage{lscape,rotating,pdflscape}

tikzset{%
button on/.style={%
draw,minimum size=5mm,
line width=1pt,
fill=blue!50,rounded corners,
switch ocg with mark on={#1}{},
},
}
begin{document}

begin{landscape}
begin{figure}[H]
begin{tikzpicture}
begin{axis}[
width=22cm,height=12cm,
legend columns=1,grid=both, legend cell align={left},
ymin=-4,ymax=4,xmin=0,xmax=4,
xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
]
begin{scope}[ocg={name=Wawe1 example,ref=Wawe1,status=invisible}]
addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
end{scope}

begin{scope}[ocg={name=Wawe2 example,ref=Wawe2,status=invisible}]
addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
end{scope}

addlegendentry{Wave1}
addlegendentry{Wave2}
end{axis}
node[button on=Wawe1]at (-2,10)(but){};
node[right=0 of but]{Wawe1};
node[below=3pt of but,button on=Wawe2](but){};
node[right=0 of but]{Wawe2};
end{tikzpicture}
end{figure}
end{landscape}

end{document}


screenshot






share|improve this answer


























  • Very nice! pagestyle{empty} would be good.

    – Sigur
    10 hours ago











  • With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

    – Sigur
    10 hours ago











  • I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

    – AndréC
    9 hours ago





















2














For 2 functions we have 2^2=4 possibilities. for more functions, the code would be much complicated.



In full screen mode, click on the check mark to navigate to pdf page and see the functions.



enter image description here



enter image description here



M(W)E



documentclass[tikz,margin=2mm]{standalone}
usepackage{pgfplots,amssymb}
usepackage[hidelinks]{hyperref}
newcommand{colorOn}{green!80!black}
newcommand{colorOff}{black!30}
begin{document}
foreach i in {0,1}{
foreach j in {0,1}{
begin{tikzpicture}
begin{axis}[
width=22cm,height=12cm,
legend columns=1,grid=both, legend cell align={left},
ymin=-4,ymax=4,xmin=0,xmax=4,
xlabel = Lenght $L$ (m), ylabel = Wave amplitude $A$ (-),
]
ifnum i=1
addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
addlegendentry{Wave1}
fi
ifnum j=1
addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
addlegendentry{Wave2}
fi
end{axis}
node[anchor=east,minimum width=4cm] (f) at (-2,6) {%
$f(x)=2sin(frac{2pi}{4}deg(x))$
ifnum i=0
ifnum j=0
hypertarget{fOffgOff}{}%
hyperlink{fOngOff}{textcolor{colorOff}{checkmark}}
else
hypertarget{fOffgOn}{}%
hyperlink{fOngOn} {textcolor{colorOff}{checkmark}}
fi
else
ifnum j=0
hypertarget{fOngOff}{}%
hyperlink{fOffgOff}{textcolor{colorOn}{checkmark}}
else
hypertarget{fOngOn}{}%
hyperlink{fOffgOn} {textcolor{colorOn}{checkmark}}
fi
fi
};
node[below of=f] (g) {%
$g(x)=2sin(frac{2pi}{5}deg(x))$
ifnum i=0
ifnum j=0
hyperlink{fOffgOn}{textcolor{colorOff}{checkmark}}
else
hyperlink{fOffgOff} {textcolor{colorOn}{checkmark}}
fi
else
ifnum j=0
hyperlink{fOngOn}{textcolor{colorOff}{checkmark}}
else
hyperlink{fOngOff} {textcolor{colorOn}{checkmark}}
fi
fi
};
end{tikzpicture}
}}
end{document}





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%2f474860%2fdynamically-hide-and-show-plots%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    To be compiled twice. Use Adobe Reader, Foxit Reader, (evince ?) or PDF readers that manage OCG layers.



    I simply adapted the code of the example given in the ocgx and ocgx2 package.
    I'll leave it to you to do the finishing touches.



    documentclass{article}

    usepackage[latin1]{inputenc}
    usepackage[T1]{fontenc}
    usepackage[french]{babel}
    usepackage{lmodern}
    usepackage[top=1.5cm, bottom=4cm, left=2cm, right=2cm]{geometry}
    %usepackage{pgf,tikz}
    usepackage[tikz]{ocgx2}
    usetikzlibrary{backgrounds,calc,shadows,chains,shapes.geometric}
    usetikzlibrary{fit}
    usetikzlibrary{matrix}
    usetikzlibrary{arrows,patterns}
    usepackage{amsmath,siunitx,xcolor}
    usepackage{pgfplotstable,pgfplots,filecontents}
    pgfplotsset{compat=1.6} %Update pgfplots package version.
    usepackage{calculator,float}
    usepackage{lscape,rotating,pdflscape}

    tikzset{%
    button on/.style={%
    draw,minimum size=5mm,
    line width=1pt,
    fill=blue!50,rounded corners,
    switch ocg with mark on={#1}{},
    },
    }
    begin{document}

    begin{landscape}
    begin{figure}[H]
    begin{tikzpicture}
    begin{axis}[
    width=22cm,height=12cm,
    legend columns=1,grid=both, legend cell align={left},
    ymin=-4,ymax=4,xmin=0,xmax=4,
    xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
    ]
    begin{scope}[ocg={name=Wawe1 example,ref=Wawe1,status=invisible}]
    addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
    end{scope}

    begin{scope}[ocg={name=Wawe2 example,ref=Wawe2,status=invisible}]
    addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
    end{scope}

    addlegendentry{Wave1}
    addlegendentry{Wave2}
    end{axis}
    node[button on=Wawe1]at (-2,10)(but){};
    node[right=0 of but]{Wawe1};
    node[below=3pt of but,button on=Wawe2](but){};
    node[right=0 of but]{Wawe2};
    end{tikzpicture}
    end{figure}
    end{landscape}

    end{document}


    screenshot






    share|improve this answer


























    • Very nice! pagestyle{empty} would be good.

      – Sigur
      10 hours ago











    • With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

      – Sigur
      10 hours ago











    • I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

      – AndréC
      9 hours ago


















    4














    To be compiled twice. Use Adobe Reader, Foxit Reader, (evince ?) or PDF readers that manage OCG layers.



    I simply adapted the code of the example given in the ocgx and ocgx2 package.
    I'll leave it to you to do the finishing touches.



    documentclass{article}

    usepackage[latin1]{inputenc}
    usepackage[T1]{fontenc}
    usepackage[french]{babel}
    usepackage{lmodern}
    usepackage[top=1.5cm, bottom=4cm, left=2cm, right=2cm]{geometry}
    %usepackage{pgf,tikz}
    usepackage[tikz]{ocgx2}
    usetikzlibrary{backgrounds,calc,shadows,chains,shapes.geometric}
    usetikzlibrary{fit}
    usetikzlibrary{matrix}
    usetikzlibrary{arrows,patterns}
    usepackage{amsmath,siunitx,xcolor}
    usepackage{pgfplotstable,pgfplots,filecontents}
    pgfplotsset{compat=1.6} %Update pgfplots package version.
    usepackage{calculator,float}
    usepackage{lscape,rotating,pdflscape}

    tikzset{%
    button on/.style={%
    draw,minimum size=5mm,
    line width=1pt,
    fill=blue!50,rounded corners,
    switch ocg with mark on={#1}{},
    },
    }
    begin{document}

    begin{landscape}
    begin{figure}[H]
    begin{tikzpicture}
    begin{axis}[
    width=22cm,height=12cm,
    legend columns=1,grid=both, legend cell align={left},
    ymin=-4,ymax=4,xmin=0,xmax=4,
    xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
    ]
    begin{scope}[ocg={name=Wawe1 example,ref=Wawe1,status=invisible}]
    addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
    end{scope}

    begin{scope}[ocg={name=Wawe2 example,ref=Wawe2,status=invisible}]
    addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
    end{scope}

    addlegendentry{Wave1}
    addlegendentry{Wave2}
    end{axis}
    node[button on=Wawe1]at (-2,10)(but){};
    node[right=0 of but]{Wawe1};
    node[below=3pt of but,button on=Wawe2](but){};
    node[right=0 of but]{Wawe2};
    end{tikzpicture}
    end{figure}
    end{landscape}

    end{document}


    screenshot






    share|improve this answer


























    • Very nice! pagestyle{empty} would be good.

      – Sigur
      10 hours ago











    • With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

      – Sigur
      10 hours ago











    • I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

      – AndréC
      9 hours ago
















    4












    4








    4







    To be compiled twice. Use Adobe Reader, Foxit Reader, (evince ?) or PDF readers that manage OCG layers.



    I simply adapted the code of the example given in the ocgx and ocgx2 package.
    I'll leave it to you to do the finishing touches.



    documentclass{article}

    usepackage[latin1]{inputenc}
    usepackage[T1]{fontenc}
    usepackage[french]{babel}
    usepackage{lmodern}
    usepackage[top=1.5cm, bottom=4cm, left=2cm, right=2cm]{geometry}
    %usepackage{pgf,tikz}
    usepackage[tikz]{ocgx2}
    usetikzlibrary{backgrounds,calc,shadows,chains,shapes.geometric}
    usetikzlibrary{fit}
    usetikzlibrary{matrix}
    usetikzlibrary{arrows,patterns}
    usepackage{amsmath,siunitx,xcolor}
    usepackage{pgfplotstable,pgfplots,filecontents}
    pgfplotsset{compat=1.6} %Update pgfplots package version.
    usepackage{calculator,float}
    usepackage{lscape,rotating,pdflscape}

    tikzset{%
    button on/.style={%
    draw,minimum size=5mm,
    line width=1pt,
    fill=blue!50,rounded corners,
    switch ocg with mark on={#1}{},
    },
    }
    begin{document}

    begin{landscape}
    begin{figure}[H]
    begin{tikzpicture}
    begin{axis}[
    width=22cm,height=12cm,
    legend columns=1,grid=both, legend cell align={left},
    ymin=-4,ymax=4,xmin=0,xmax=4,
    xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
    ]
    begin{scope}[ocg={name=Wawe1 example,ref=Wawe1,status=invisible}]
    addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
    end{scope}

    begin{scope}[ocg={name=Wawe2 example,ref=Wawe2,status=invisible}]
    addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
    end{scope}

    addlegendentry{Wave1}
    addlegendentry{Wave2}
    end{axis}
    node[button on=Wawe1]at (-2,10)(but){};
    node[right=0 of but]{Wawe1};
    node[below=3pt of but,button on=Wawe2](but){};
    node[right=0 of but]{Wawe2};
    end{tikzpicture}
    end{figure}
    end{landscape}

    end{document}


    screenshot






    share|improve this answer















    To be compiled twice. Use Adobe Reader, Foxit Reader, (evince ?) or PDF readers that manage OCG layers.



    I simply adapted the code of the example given in the ocgx and ocgx2 package.
    I'll leave it to you to do the finishing touches.



    documentclass{article}

    usepackage[latin1]{inputenc}
    usepackage[T1]{fontenc}
    usepackage[french]{babel}
    usepackage{lmodern}
    usepackage[top=1.5cm, bottom=4cm, left=2cm, right=2cm]{geometry}
    %usepackage{pgf,tikz}
    usepackage[tikz]{ocgx2}
    usetikzlibrary{backgrounds,calc,shadows,chains,shapes.geometric}
    usetikzlibrary{fit}
    usetikzlibrary{matrix}
    usetikzlibrary{arrows,patterns}
    usepackage{amsmath,siunitx,xcolor}
    usepackage{pgfplotstable,pgfplots,filecontents}
    pgfplotsset{compat=1.6} %Update pgfplots package version.
    usepackage{calculator,float}
    usepackage{lscape,rotating,pdflscape}

    tikzset{%
    button on/.style={%
    draw,minimum size=5mm,
    line width=1pt,
    fill=blue!50,rounded corners,
    switch ocg with mark on={#1}{},
    },
    }
    begin{document}

    begin{landscape}
    begin{figure}[H]
    begin{tikzpicture}
    begin{axis}[
    width=22cm,height=12cm,
    legend columns=1,grid=both, legend cell align={left},
    ymin=-4,ymax=4,xmin=0,xmax=4,
    xlabel = Lenght L (m),ylabel = Wave amplitude A (-),
    ]
    begin{scope}[ocg={name=Wawe1 example,ref=Wawe1,status=invisible}]
    addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
    end{scope}

    begin{scope}[ocg={name=Wawe2 example,ref=Wawe2,status=invisible}]
    addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
    end{scope}

    addlegendentry{Wave1}
    addlegendentry{Wave2}
    end{axis}
    node[button on=Wawe1]at (-2,10)(but){};
    node[right=0 of but]{Wawe1};
    node[below=3pt of but,button on=Wawe2](but){};
    node[right=0 of but]{Wawe2};
    end{tikzpicture}
    end{figure}
    end{landscape}

    end{document}


    screenshot







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 9 hours ago

























    answered 10 hours ago









    AndréCAndréC

    9,08411447




    9,08411447













    • Very nice! pagestyle{empty} would be good.

      – Sigur
      10 hours ago











    • With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

      – Sigur
      10 hours ago











    • I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

      – AndréC
      9 hours ago





















    • Very nice! pagestyle{empty} would be good.

      – Sigur
      10 hours ago











    • With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

      – Sigur
      10 hours ago











    • I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

      – AndréC
      9 hours ago



















    Very nice! pagestyle{empty} would be good.

    – Sigur
    10 hours ago





    Very nice! pagestyle{empty} would be good.

    – Sigur
    10 hours ago













    With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

    – Sigur
    10 hours ago





    With evince in Linux Mint, in full screen mode, the button does not work, since when clicked on it, it goes to next page, that is, end of file. Maybe a problem with my evince.

    – Sigur
    10 hours ago













    I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

    – AndréC
    9 hours ago







    I don't have evince and therefore I can't test. This compatibility is the one given by Paul Gaborit in his demo of the ocgx package here: mirrors.rit.edu/CTAN/macros/latex/contrib/ocgx/demo-ocgx.pdf pagestyle{empty} would be good but it's his MWE

    – AndréC
    9 hours ago













    2














    For 2 functions we have 2^2=4 possibilities. for more functions, the code would be much complicated.



    In full screen mode, click on the check mark to navigate to pdf page and see the functions.



    enter image description here



    enter image description here



    M(W)E



    documentclass[tikz,margin=2mm]{standalone}
    usepackage{pgfplots,amssymb}
    usepackage[hidelinks]{hyperref}
    newcommand{colorOn}{green!80!black}
    newcommand{colorOff}{black!30}
    begin{document}
    foreach i in {0,1}{
    foreach j in {0,1}{
    begin{tikzpicture}
    begin{axis}[
    width=22cm,height=12cm,
    legend columns=1,grid=both, legend cell align={left},
    ymin=-4,ymax=4,xmin=0,xmax=4,
    xlabel = Lenght $L$ (m), ylabel = Wave amplitude $A$ (-),
    ]
    ifnum i=1
    addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
    addlegendentry{Wave1}
    fi
    ifnum j=1
    addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
    addlegendentry{Wave2}
    fi
    end{axis}
    node[anchor=east,minimum width=4cm] (f) at (-2,6) {%
    $f(x)=2sin(frac{2pi}{4}deg(x))$
    ifnum i=0
    ifnum j=0
    hypertarget{fOffgOff}{}%
    hyperlink{fOngOff}{textcolor{colorOff}{checkmark}}
    else
    hypertarget{fOffgOn}{}%
    hyperlink{fOngOn} {textcolor{colorOff}{checkmark}}
    fi
    else
    ifnum j=0
    hypertarget{fOngOff}{}%
    hyperlink{fOffgOff}{textcolor{colorOn}{checkmark}}
    else
    hypertarget{fOngOn}{}%
    hyperlink{fOffgOn} {textcolor{colorOn}{checkmark}}
    fi
    fi
    };
    node[below of=f] (g) {%
    $g(x)=2sin(frac{2pi}{5}deg(x))$
    ifnum i=0
    ifnum j=0
    hyperlink{fOffgOn}{textcolor{colorOff}{checkmark}}
    else
    hyperlink{fOffgOff} {textcolor{colorOn}{checkmark}}
    fi
    else
    ifnum j=0
    hyperlink{fOngOn}{textcolor{colorOff}{checkmark}}
    else
    hyperlink{fOngOff} {textcolor{colorOn}{checkmark}}
    fi
    fi
    };
    end{tikzpicture}
    }}
    end{document}





    share|improve this answer






























      2














      For 2 functions we have 2^2=4 possibilities. for more functions, the code would be much complicated.



      In full screen mode, click on the check mark to navigate to pdf page and see the functions.



      enter image description here



      enter image description here



      M(W)E



      documentclass[tikz,margin=2mm]{standalone}
      usepackage{pgfplots,amssymb}
      usepackage[hidelinks]{hyperref}
      newcommand{colorOn}{green!80!black}
      newcommand{colorOff}{black!30}
      begin{document}
      foreach i in {0,1}{
      foreach j in {0,1}{
      begin{tikzpicture}
      begin{axis}[
      width=22cm,height=12cm,
      legend columns=1,grid=both, legend cell align={left},
      ymin=-4,ymax=4,xmin=0,xmax=4,
      xlabel = Lenght $L$ (m), ylabel = Wave amplitude $A$ (-),
      ]
      ifnum i=1
      addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
      addlegendentry{Wave1}
      fi
      ifnum j=1
      addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
      addlegendentry{Wave2}
      fi
      end{axis}
      node[anchor=east,minimum width=4cm] (f) at (-2,6) {%
      $f(x)=2sin(frac{2pi}{4}deg(x))$
      ifnum i=0
      ifnum j=0
      hypertarget{fOffgOff}{}%
      hyperlink{fOngOff}{textcolor{colorOff}{checkmark}}
      else
      hypertarget{fOffgOn}{}%
      hyperlink{fOngOn} {textcolor{colorOff}{checkmark}}
      fi
      else
      ifnum j=0
      hypertarget{fOngOff}{}%
      hyperlink{fOffgOff}{textcolor{colorOn}{checkmark}}
      else
      hypertarget{fOngOn}{}%
      hyperlink{fOffgOn} {textcolor{colorOn}{checkmark}}
      fi
      fi
      };
      node[below of=f] (g) {%
      $g(x)=2sin(frac{2pi}{5}deg(x))$
      ifnum i=0
      ifnum j=0
      hyperlink{fOffgOn}{textcolor{colorOff}{checkmark}}
      else
      hyperlink{fOffgOff} {textcolor{colorOn}{checkmark}}
      fi
      else
      ifnum j=0
      hyperlink{fOngOn}{textcolor{colorOff}{checkmark}}
      else
      hyperlink{fOngOff} {textcolor{colorOn}{checkmark}}
      fi
      fi
      };
      end{tikzpicture}
      }}
      end{document}





      share|improve this answer




























        2












        2








        2







        For 2 functions we have 2^2=4 possibilities. for more functions, the code would be much complicated.



        In full screen mode, click on the check mark to navigate to pdf page and see the functions.



        enter image description here



        enter image description here



        M(W)E



        documentclass[tikz,margin=2mm]{standalone}
        usepackage{pgfplots,amssymb}
        usepackage[hidelinks]{hyperref}
        newcommand{colorOn}{green!80!black}
        newcommand{colorOff}{black!30}
        begin{document}
        foreach i in {0,1}{
        foreach j in {0,1}{
        begin{tikzpicture}
        begin{axis}[
        width=22cm,height=12cm,
        legend columns=1,grid=both, legend cell align={left},
        ymin=-4,ymax=4,xmin=0,xmax=4,
        xlabel = Lenght $L$ (m), ylabel = Wave amplitude $A$ (-),
        ]
        ifnum i=1
        addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
        addlegendentry{Wave1}
        fi
        ifnum j=1
        addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
        addlegendentry{Wave2}
        fi
        end{axis}
        node[anchor=east,minimum width=4cm] (f) at (-2,6) {%
        $f(x)=2sin(frac{2pi}{4}deg(x))$
        ifnum i=0
        ifnum j=0
        hypertarget{fOffgOff}{}%
        hyperlink{fOngOff}{textcolor{colorOff}{checkmark}}
        else
        hypertarget{fOffgOn}{}%
        hyperlink{fOngOn} {textcolor{colorOff}{checkmark}}
        fi
        else
        ifnum j=0
        hypertarget{fOngOff}{}%
        hyperlink{fOffgOff}{textcolor{colorOn}{checkmark}}
        else
        hypertarget{fOngOn}{}%
        hyperlink{fOffgOn} {textcolor{colorOn}{checkmark}}
        fi
        fi
        };
        node[below of=f] (g) {%
        $g(x)=2sin(frac{2pi}{5}deg(x))$
        ifnum i=0
        ifnum j=0
        hyperlink{fOffgOn}{textcolor{colorOff}{checkmark}}
        else
        hyperlink{fOffgOff} {textcolor{colorOn}{checkmark}}
        fi
        else
        ifnum j=0
        hyperlink{fOngOn}{textcolor{colorOff}{checkmark}}
        else
        hyperlink{fOngOff} {textcolor{colorOn}{checkmark}}
        fi
        fi
        };
        end{tikzpicture}
        }}
        end{document}





        share|improve this answer















        For 2 functions we have 2^2=4 possibilities. for more functions, the code would be much complicated.



        In full screen mode, click on the check mark to navigate to pdf page and see the functions.



        enter image description here



        enter image description here



        M(W)E



        documentclass[tikz,margin=2mm]{standalone}
        usepackage{pgfplots,amssymb}
        usepackage[hidelinks]{hyperref}
        newcommand{colorOn}{green!80!black}
        newcommand{colorOff}{black!30}
        begin{document}
        foreach i in {0,1}{
        foreach j in {0,1}{
        begin{tikzpicture}
        begin{axis}[
        width=22cm,height=12cm,
        legend columns=1,grid=both, legend cell align={left},
        ymin=-4,ymax=4,xmin=0,xmax=4,
        xlabel = Lenght $L$ (m), ylabel = Wave amplitude $A$ (-),
        ]
        ifnum i=1
        addplot[domain=0:4,samples=200,red] {2*sin(2*pi/4*deg(x))};
        addlegendentry{Wave1}
        fi
        ifnum j=1
        addplot[domain=0:4,samples=200,blue] {2*sin(2*pi/5*deg((x))};
        addlegendentry{Wave2}
        fi
        end{axis}
        node[anchor=east,minimum width=4cm] (f) at (-2,6) {%
        $f(x)=2sin(frac{2pi}{4}deg(x))$
        ifnum i=0
        ifnum j=0
        hypertarget{fOffgOff}{}%
        hyperlink{fOngOff}{textcolor{colorOff}{checkmark}}
        else
        hypertarget{fOffgOn}{}%
        hyperlink{fOngOn} {textcolor{colorOff}{checkmark}}
        fi
        else
        ifnum j=0
        hypertarget{fOngOff}{}%
        hyperlink{fOffgOff}{textcolor{colorOn}{checkmark}}
        else
        hypertarget{fOngOn}{}%
        hyperlink{fOffgOn} {textcolor{colorOn}{checkmark}}
        fi
        fi
        };
        node[below of=f] (g) {%
        $g(x)=2sin(frac{2pi}{5}deg(x))$
        ifnum i=0
        ifnum j=0
        hyperlink{fOffgOn}{textcolor{colorOff}{checkmark}}
        else
        hyperlink{fOffgOff} {textcolor{colorOn}{checkmark}}
        fi
        else
        ifnum j=0
        hyperlink{fOngOn}{textcolor{colorOff}{checkmark}}
        else
        hyperlink{fOngOff} {textcolor{colorOn}{checkmark}}
        fi
        fi
        };
        end{tikzpicture}
        }}
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 8 hours ago

























        answered 10 hours ago









        SigurSigur

        24.8k356139




        24.8k356139






























            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%2f474860%2fdynamically-hide-and-show-plots%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

            Category:香港粉麵

            List *all* the tuples!

            Channel [V]