Annotating a TIKZ Diagram












5















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



























    5















    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

























      5












      5








      5


      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














      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













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 10:31









      user175199user175199

      534




      534






















          2 Answers
          2






          active

          oldest

          votes


















          4














          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































            1














            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
              Nov 22 '18 at 4:34











            • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

              – user175199
              Nov 22 '18 at 4:44











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









            4














            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




























              4














              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


























                4












                4








                4







                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 Nov 21 '18 at 11:31









                IgnasiIgnasi

                93.3k4167310




                93.3k4167310























                    1














                    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
                      Nov 22 '18 at 4:34











                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

                      – user175199
                      Nov 22 '18 at 4:44
















                    1














                    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
                      Nov 22 '18 at 4:34











                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

                      – user175199
                      Nov 22 '18 at 4:44














                    1












                    1








                    1







                    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 Nov 21 '18 at 15:28









                    marmotmarmot

                    100k4115222




                    100k4115222













                    • 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
                      Nov 22 '18 at 4:34











                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

                      – user175199
                      Nov 22 '18 at 4:44



















                    • 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
                      Nov 22 '18 at 4:34











                    • nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

                      – user175199
                      Nov 22 '18 at 4:44

















                    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
                    Nov 22 '18 at 4:34





                    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
                    Nov 22 '18 at 4:34













                    nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

                    – user175199
                    Nov 22 '18 at 4:44





                    nevermind got it has to add the coordinates as well - thanks again marmot and Ignasi !

                    – user175199
                    Nov 22 '18 at 4:44


















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

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith