Annotating a TIKZ Diagram
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 ..
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
add a comment |
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 ..
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
add a comment |
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 ..
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
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 ..
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
tikz-pgf
asked Nov 21 '18 at 10:31
user175199user175199
534
534
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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}
add a comment |
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}
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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}
add a comment |
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}
add a comment |
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}
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}
answered Nov 21 '18 at 11:31
IgnasiIgnasi
93.3k4167310
93.3k4167310
add a comment |
add a comment |
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}
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
add a comment |
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}
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
add a comment |
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}
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}
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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