Annotating a TIKZ Diagram











up vote
5
down vote

favorite
1












I have the following diagram and I'd like to annotate and add some arrows but getting a little rotate-confused with the lines and text. I've attached the tikz code I'm working with below and an image with the lines and labels drawn in ..



enter image description here



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.14}
begin{document}

pgfmathsetmacro{offset}{0.05}
begin{tikzpicture}[font=sffamilysmall,
declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
addplot [domain=-3:3] ({gauss(x,1,0)},x);
addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

coordinate (t0) at (-0.45,-4.1);
coordinate (t) at (2,-4.1);
coordinate (xi) at (-0.5,4);
addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
end{axis}

foreach X in {1,2}
{
draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
}

node[anchor=north east] at (t) {time};
node[anchor=north east] at (xi) {$X$};

end{tikzpicture}
end{document}









share|improve this question







New contributor




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
























    up vote
    5
    down vote

    favorite
    1












    I have the following diagram and I'd like to annotate and add some arrows but getting a little rotate-confused with the lines and text. I've attached the tikz code I'm working with below and an image with the lines and labels drawn in ..



    enter image description here



    documentclass[tikz,border=3.14mm]{standalone}
    usepackage{pgfplots}
    pgfplotsset{compat=1.14}
    begin{document}

    pgfmathsetmacro{offset}{0.05}
    begin{tikzpicture}[font=sffamilysmall,
    declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

    begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
    addplot [domain=-3:3] ({gauss(x,1,0)},x);
    addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

    draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
    draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
    addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
    path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

    coordinate (t0) at (-0.45,-4.1);
    coordinate (t) at (2,-4.1);
    coordinate (xi) at (-0.5,4);
    addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
    end{axis}

    foreach X in {1,2}
    {
    draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
    draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
    }

    node[anchor=north east] at (t) {time};
    node[anchor=north east] at (xi) {$X$};

    end{tikzpicture}
    end{document}









    share|improve this question







    New contributor




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






















      up vote
      5
      down vote

      favorite
      1









      up vote
      5
      down vote

      favorite
      1






      1





      I have the following diagram and I'd like to annotate and add some arrows but getting a little rotate-confused with the lines and text. I've attached the tikz code I'm working with below and an image with the lines and labels drawn in ..



      enter image description here



      documentclass[tikz,border=3.14mm]{standalone}
      usepackage{pgfplots}
      pgfplotsset{compat=1.14}
      begin{document}

      pgfmathsetmacro{offset}{0.05}
      begin{tikzpicture}[font=sffamilysmall,
      declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

      begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
      addplot [domain=-3:3] ({gauss(x,1,0)},x);
      addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

      draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
      draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
      addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
      path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

      coordinate (t0) at (-0.45,-4.1);
      coordinate (t) at (2,-4.1);
      coordinate (xi) at (-0.5,4);
      addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
      end{axis}

      foreach X in {1,2}
      {
      draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
      draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
      }

      node[anchor=north east] at (t) {time};
      node[anchor=north east] at (xi) {$X$};

      end{tikzpicture}
      end{document}









      share|improve this question







      New contributor




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











      I have the following diagram and I'd like to annotate and add some arrows but getting a little rotate-confused with the lines and text. I've attached the tikz code I'm working with below and an image with the lines and labels drawn in ..



      enter image description here



      documentclass[tikz,border=3.14mm]{standalone}
      usepackage{pgfplots}
      pgfplotsset{compat=1.14}
      begin{document}

      pgfmathsetmacro{offset}{0.05}
      begin{tikzpicture}[font=sffamilysmall,
      declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

      begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
      addplot [domain=-3:3] ({gauss(x,1,0)},x);
      addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

      draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
      draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
      addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
      path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

      coordinate (t0) at (-0.45,-4.1);
      coordinate (t) at (2,-4.1);
      coordinate (xi) at (-0.5,4);
      addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
      end{axis}

      foreach X in {1,2}
      {
      draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
      draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
      }

      node[anchor=north east] at (t) {time};
      node[anchor=north east] at (xi) {$X$};

      end{tikzpicture}
      end{document}






      tikz-pgf






      share|improve this question







      New contributor




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











      share|improve this question







      New contributor




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









      share|improve this question




      share|improve this question






      New contributor




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









      asked yesterday









      user175199

      262




      262




      New contributor




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





      New contributor





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






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






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote













          You can add the lines inside axis and use these coordinates. I've also added clips=false to avoid problems with tip arrow draw below the axis.



          documentclass[tikz,border=4mm]{standalone}
          usepackage{pgfplots}
          pgfplotsset{compat=1.14}
          begin{document}

          pgfmathsetmacro{offset}{0.05}
          begin{tikzpicture}[font=sffamilysmall,
          declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

          begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm, clip=false]
          addplot [domain=-3:3] ({gauss(x,1,0)},x);
          addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

          draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
          draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
          addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
          path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

          coordinate (t0) at (-0.45,-4.1);
          coordinate (t) at (2,-4.1);
          coordinate (xi) at (-0.5,4);
          addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis

          draw[->, red] (-0.5,-5)--(0,-5) node[above,midway]{A};
          draw[->,red] (0,-1) node[left]{B}--({1+gauss(-1,1,0)},-1)node[below right]{C};
          end{axis}

          foreach X in {1,2}
          {
          draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
          draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
          }

          node[anchor=north east] at (t) {time};
          node[anchor=north east] at (xi) {$X$};


          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer




























            up vote
            1
            down vote













            You have the parametrizations of the Gaussians, so it is easy to define the points B and C as a function of some input parameter, which I call xp here. And then you already export coordinates out of the axis, you could also do this for the arrow labelled A: just draw it outside of the axis. Then there is no need to switch off clip. (In the present setting, you could switch off clip, as demonstrated by Ignasi, but if you are to add more ingredients to your plot, this might not be the optimal way because often enough it is good to have pgfplots clip away auxiliary stuff.)



            documentclass[tikz,border=3.14mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.14}
            begin{document}

            pgfmathsetmacro{offset}{0.05}
            pgfmathsetmacro{xp}{-1}
            begin{tikzpicture}[font=sffamilysmall,
            declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

            begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
            addplot [domain=-3:3] ({gauss(x,1,0)},x);
            addplot [domain=-3:3] ({1+gauss(x,1,0)},x);


            draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
            draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
            addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
            path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3)
            (-0.5,-5) coordinate (h1) (0,-5) coordinate (h2);

            coordinate (t0) at (-0.45,-4.1);
            coordinate (t) at (2,-4.1);
            coordinate (xi) at (-0.5,4);
            addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
            coordinate (start) at (0,xp);
            coordinate (end) at ({1+gauss(xp,1,0)},xp);
            end{axis}

            foreach X in {1,2}
            {
            draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
            draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
            }

            draw[red,-latex] (start) node[left]{B}
            -- (end) node[below right]{C};
            draw[red,-latex] (h1) -- (h2) node[midway,above]{A};

            node[anchor=north east] at (t) {time};
            node[anchor=north east] at (xi) {$X$};

            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer





















            • this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
              – user175199
              yesterday










            • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
              – user175199
              23 hours ago











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            user175199 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%2f461087%2fannotating-a-tikz-diagram%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








            up vote
            4
            down vote













            You can add the lines inside axis and use these coordinates. I've also added clips=false to avoid problems with tip arrow draw below the axis.



            documentclass[tikz,border=4mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.14}
            begin{document}

            pgfmathsetmacro{offset}{0.05}
            begin{tikzpicture}[font=sffamilysmall,
            declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

            begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm, clip=false]
            addplot [domain=-3:3] ({gauss(x,1,0)},x);
            addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

            draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
            draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
            addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
            path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

            coordinate (t0) at (-0.45,-4.1);
            coordinate (t) at (2,-4.1);
            coordinate (xi) at (-0.5,4);
            addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis

            draw[->, red] (-0.5,-5)--(0,-5) node[above,midway]{A};
            draw[->,red] (0,-1) node[left]{B}--({1+gauss(-1,1,0)},-1)node[below right]{C};
            end{axis}

            foreach X in {1,2}
            {
            draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
            draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
            }

            node[anchor=north east] at (t) {time};
            node[anchor=north east] at (xi) {$X$};


            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer

























              up vote
              4
              down vote













              You can add the lines inside axis and use these coordinates. I've also added clips=false to avoid problems with tip arrow draw below the axis.



              documentclass[tikz,border=4mm]{standalone}
              usepackage{pgfplots}
              pgfplotsset{compat=1.14}
              begin{document}

              pgfmathsetmacro{offset}{0.05}
              begin{tikzpicture}[font=sffamilysmall,
              declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

              begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm, clip=false]
              addplot [domain=-3:3] ({gauss(x,1,0)},x);
              addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

              draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
              draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
              addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
              path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

              coordinate (t0) at (-0.45,-4.1);
              coordinate (t) at (2,-4.1);
              coordinate (xi) at (-0.5,4);
              addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis

              draw[->, red] (-0.5,-5)--(0,-5) node[above,midway]{A};
              draw[->,red] (0,-1) node[left]{B}--({1+gauss(-1,1,0)},-1)node[below right]{C};
              end{axis}

              foreach X in {1,2}
              {
              draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
              draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
              }

              node[anchor=north east] at (t) {time};
              node[anchor=north east] at (xi) {$X$};


              end{tikzpicture}
              end{document}


              enter image description here






              share|improve this answer























                up vote
                4
                down vote










                up vote
                4
                down vote









                You can add the lines inside axis and use these coordinates. I've also added clips=false to avoid problems with tip arrow draw below the axis.



                documentclass[tikz,border=4mm]{standalone}
                usepackage{pgfplots}
                pgfplotsset{compat=1.14}
                begin{document}

                pgfmathsetmacro{offset}{0.05}
                begin{tikzpicture}[font=sffamilysmall,
                declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

                begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm, clip=false]
                addplot [domain=-3:3] ({gauss(x,1,0)},x);
                addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

                draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
                draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
                addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
                path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

                coordinate (t0) at (-0.45,-4.1);
                coordinate (t) at (2,-4.1);
                coordinate (xi) at (-0.5,4);
                addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis

                draw[->, red] (-0.5,-5)--(0,-5) node[above,midway]{A};
                draw[->,red] (0,-1) node[left]{B}--({1+gauss(-1,1,0)},-1)node[below right]{C};
                end{axis}

                foreach X in {1,2}
                {
                draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
                draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
                }

                node[anchor=north east] at (t) {time};
                node[anchor=north east] at (xi) {$X$};


                end{tikzpicture}
                end{document}


                enter image description here






                share|improve this answer












                You can add the lines inside axis and use these coordinates. I've also added clips=false to avoid problems with tip arrow draw below the axis.



                documentclass[tikz,border=4mm]{standalone}
                usepackage{pgfplots}
                pgfplotsset{compat=1.14}
                begin{document}

                pgfmathsetmacro{offset}{0.05}
                begin{tikzpicture}[font=sffamilysmall,
                declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

                begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm, clip=false]
                addplot [domain=-3:3] ({gauss(x,1,0)},x);
                addplot [domain=-3:3] ({1+gauss(x,1,0)},x);

                draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
                draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
                addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
                path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);

                coordinate (t0) at (-0.45,-4.1);
                coordinate (t) at (2,-4.1);
                coordinate (xi) at (-0.5,4);
                addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis

                draw[->, red] (-0.5,-5)--(0,-5) node[above,midway]{A};
                draw[->,red] (0,-1) node[left]{B}--({1+gauss(-1,1,0)},-1)node[below right]{C};
                end{axis}

                foreach X in {1,2}
                {
                draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
                draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
                }

                node[anchor=north east] at (t) {time};
                node[anchor=north east] at (xi) {$X$};


                end{tikzpicture}
                end{document}


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                Ignasi

                90.2k4163302




                90.2k4163302






















                    up vote
                    1
                    down vote













                    You have the parametrizations of the Gaussians, so it is easy to define the points B and C as a function of some input parameter, which I call xp here. And then you already export coordinates out of the axis, you could also do this for the arrow labelled A: just draw it outside of the axis. Then there is no need to switch off clip. (In the present setting, you could switch off clip, as demonstrated by Ignasi, but if you are to add more ingredients to your plot, this might not be the optimal way because often enough it is good to have pgfplots clip away auxiliary stuff.)



                    documentclass[tikz,border=3.14mm]{standalone}
                    usepackage{pgfplots}
                    pgfplotsset{compat=1.14}
                    begin{document}

                    pgfmathsetmacro{offset}{0.05}
                    pgfmathsetmacro{xp}{-1}
                    begin{tikzpicture}[font=sffamilysmall,
                    declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

                    begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
                    addplot [domain=-3:3] ({gauss(x,1,0)},x);
                    addplot [domain=-3:3] ({1+gauss(x,1,0)},x);


                    draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
                    draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
                    addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
                    path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3)
                    (-0.5,-5) coordinate (h1) (0,-5) coordinate (h2);

                    coordinate (t0) at (-0.45,-4.1);
                    coordinate (t) at (2,-4.1);
                    coordinate (xi) at (-0.5,4);
                    addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
                    coordinate (start) at (0,xp);
                    coordinate (end) at ({1+gauss(xp,1,0)},xp);
                    end{axis}

                    foreach X in {1,2}
                    {
                    draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
                    draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
                    }

                    draw[red,-latex] (start) node[left]{B}
                    -- (end) node[below right]{C};
                    draw[red,-latex] (h1) -- (h2) node[midway,above]{A};

                    node[anchor=north east] at (t) {time};
                    node[anchor=north east] at (xi) {$X$};

                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer





















                    • this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
                      – user175199
                      yesterday










                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
                      – user175199
                      23 hours ago















                    up vote
                    1
                    down vote













                    You have the parametrizations of the Gaussians, so it is easy to define the points B and C as a function of some input parameter, which I call xp here. And then you already export coordinates out of the axis, you could also do this for the arrow labelled A: just draw it outside of the axis. Then there is no need to switch off clip. (In the present setting, you could switch off clip, as demonstrated by Ignasi, but if you are to add more ingredients to your plot, this might not be the optimal way because often enough it is good to have pgfplots clip away auxiliary stuff.)



                    documentclass[tikz,border=3.14mm]{standalone}
                    usepackage{pgfplots}
                    pgfplotsset{compat=1.14}
                    begin{document}

                    pgfmathsetmacro{offset}{0.05}
                    pgfmathsetmacro{xp}{-1}
                    begin{tikzpicture}[font=sffamilysmall,
                    declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

                    begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
                    addplot [domain=-3:3] ({gauss(x,1,0)},x);
                    addplot [domain=-3:3] ({1+gauss(x,1,0)},x);


                    draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
                    draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
                    addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
                    path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3)
                    (-0.5,-5) coordinate (h1) (0,-5) coordinate (h2);

                    coordinate (t0) at (-0.45,-4.1);
                    coordinate (t) at (2,-4.1);
                    coordinate (xi) at (-0.5,4);
                    addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
                    coordinate (start) at (0,xp);
                    coordinate (end) at ({1+gauss(xp,1,0)},xp);
                    end{axis}

                    foreach X in {1,2}
                    {
                    draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
                    draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
                    }

                    draw[red,-latex] (start) node[left]{B}
                    -- (end) node[below right]{C};
                    draw[red,-latex] (h1) -- (h2) node[midway,above]{A};

                    node[anchor=north east] at (t) {time};
                    node[anchor=north east] at (xi) {$X$};

                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer





















                    • this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
                      – user175199
                      yesterday










                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
                      – user175199
                      23 hours ago













                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    You have the parametrizations of the Gaussians, so it is easy to define the points B and C as a function of some input parameter, which I call xp here. And then you already export coordinates out of the axis, you could also do this for the arrow labelled A: just draw it outside of the axis. Then there is no need to switch off clip. (In the present setting, you could switch off clip, as demonstrated by Ignasi, but if you are to add more ingredients to your plot, this might not be the optimal way because often enough it is good to have pgfplots clip away auxiliary stuff.)



                    documentclass[tikz,border=3.14mm]{standalone}
                    usepackage{pgfplots}
                    pgfplotsset{compat=1.14}
                    begin{document}

                    pgfmathsetmacro{offset}{0.05}
                    pgfmathsetmacro{xp}{-1}
                    begin{tikzpicture}[font=sffamilysmall,
                    declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

                    begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
                    addplot [domain=-3:3] ({gauss(x,1,0)},x);
                    addplot [domain=-3:3] ({1+gauss(x,1,0)},x);


                    draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
                    draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
                    addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
                    path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3)
                    (-0.5,-5) coordinate (h1) (0,-5) coordinate (h2);

                    coordinate (t0) at (-0.45,-4.1);
                    coordinate (t) at (2,-4.1);
                    coordinate (xi) at (-0.5,4);
                    addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
                    coordinate (start) at (0,xp);
                    coordinate (end) at ({1+gauss(xp,1,0)},xp);
                    end{axis}

                    foreach X in {1,2}
                    {
                    draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
                    draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
                    }

                    draw[red,-latex] (start) node[left]{B}
                    -- (end) node[below right]{C};
                    draw[red,-latex] (h1) -- (h2) node[midway,above]{A};

                    node[anchor=north east] at (t) {time};
                    node[anchor=north east] at (xi) {$X$};

                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer












                    You have the parametrizations of the Gaussians, so it is easy to define the points B and C as a function of some input parameter, which I call xp here. And then you already export coordinates out of the axis, you could also do this for the arrow labelled A: just draw it outside of the axis. Then there is no need to switch off clip. (In the present setting, you could switch off clip, as demonstrated by Ignasi, but if you are to add more ingredients to your plot, this might not be the optimal way because often enough it is good to have pgfplots clip away auxiliary stuff.)



                    documentclass[tikz,border=3.14mm]{standalone}
                    usepackage{pgfplots}
                    pgfplotsset{compat=1.14}
                    begin{document}

                    pgfmathsetmacro{offset}{0.05}
                    pgfmathsetmacro{xp}{-1}
                    begin{tikzpicture}[font=sffamilysmall,
                    declare function={gauss(x,y,z)=offset+1.2/(y*sqrt(2*pi))*exp(-((x- z)^2)/(2*y^2));}]

                    begin{axis}[samples=101,smooth,hide axis,width=20cm,height=8cm]
                    addplot [domain=-3:3] ({gauss(x,1,0)},x);
                    addplot [domain=-3:3] ({1+gauss(x,1,0)},x);


                    draw[-latex] (0,-3) -- (0,3) coordinate[pos=0.35](x1) coordinate[pos=0.5] (y1) node[below right,rotate=-90]{$X_k$};
                    draw[-latex] (1,-3) -- (1,3) coordinate[pos=0.60](x2) coordinate[pos=0.5](y2) node[below right,rotate=-90]{$X_1$};
                    addplot[-latex] coordinates{(-0.5,-4) (2,-4)};
                    path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3)
                    (-0.5,-5) coordinate (h1) (0,-5) coordinate (h2);

                    coordinate (t0) at (-0.45,-4.1);
                    coordinate (t) at (2,-4.1);
                    coordinate (xi) at (-0.5,4);
                    addplot[-latex] coordinates{(-0.5,-4.2) (-0.5,4)}; % yaxis
                    coordinate (start) at (0,xp);
                    coordinate (end) at ({1+gauss(xp,1,0)},xp);
                    end{axis}

                    foreach X in {1,2}
                    {
                    draw ([xshift=-1mm]yX) -- ([xshift=1mm]yX);
                    draw ([yshift=1mm]zX) -- ([yshift=-1mm]zX) node[below] {$t_X$};
                    }

                    draw[red,-latex] (start) node[left]{B}
                    -- (end) node[below right]{C};
                    draw[red,-latex] (h1) -- (h2) node[midway,above]{A};

                    node[anchor=north east] at (t) {time};
                    node[anchor=north east] at (xi) {$X$};

                    end{tikzpicture}
                    end{document}


                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered yesterday









                    marmot

                    77.1k487162




                    77.1k487162












                    • this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
                      – user175199
                      yesterday










                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
                      – user175199
                      23 hours ago


















                    • this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
                      – user175199
                      yesterday










                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
                      – user175199
                      23 hours ago
















                    this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
                    – user175199
                    yesterday




                    this is awesome thank you .. just one quick question if i want to add a second arrow/label below A that starts at the same position but ends at t2 how would i go about doing it? i keep getting an error when i try to duplicate A ..
                    – user175199
                    yesterday












                    nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
                    – user175199
                    23 hours ago




                    nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !
                    – user175199
                    23 hours ago










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










                     

                    draft saved


                    draft discarded


















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













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












                    user175199 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%2f461087%2fannotating-a-tikz-diagram%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

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt