Drawing arrow between plots (table datas)
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I use pfgplots
to draw two sets of data, stored in .dat
. Now I would like to automatically draw an arrow from one curve to the other, and only at the curves points. I tried to name the paths, but to no avail... Here is my minimum working example:
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
begindocument
begintikzpicture
%graphique
beginaxis
addplot[name path=c1,blue,thick,mark=*] plot table[x=a,y=b]data1.dat;
addplot[name path=c2,black,thick,mark=*] plot table[x=a,y=b]data2.dat;
%draw[red,->] (c1) -- (c2);
endaxis
endtikzpicture
enddocument
Which gives:
I would like to get (automatically from data points):
To generate this last picture I defined each arrow separately, for example for the last arrow: draw[red,-latex,thick,shorten >=0.1em] (3,1.5) -- (3,1.6);
I tryed to use the fillbetween
package to name the paths, but I have not been able to use it so far. Could I get something like : draw[red,->] (c1) -- (c2);
?
Thanks a lot for your help!
tikz-pgf pgfplots arrows tikz-datavisualization
add a comment |Â
up vote
3
down vote
favorite
I use pfgplots
to draw two sets of data, stored in .dat
. Now I would like to automatically draw an arrow from one curve to the other, and only at the curves points. I tried to name the paths, but to no avail... Here is my minimum working example:
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
begindocument
begintikzpicture
%graphique
beginaxis
addplot[name path=c1,blue,thick,mark=*] plot table[x=a,y=b]data1.dat;
addplot[name path=c2,black,thick,mark=*] plot table[x=a,y=b]data2.dat;
%draw[red,->] (c1) -- (c2);
endaxis
endtikzpicture
enddocument
Which gives:
I would like to get (automatically from data points):
To generate this last picture I defined each arrow separately, for example for the last arrow: draw[red,-latex,thick,shorten >=0.1em] (3,1.5) -- (3,1.6);
I tryed to use the fillbetween
package to name the paths, but I have not been able to use it so far. Could I get something like : draw[red,->] (c1) -- (c2);
?
Thanks a lot for your help!
tikz-pgf pgfplots arrows tikz-datavisualization
So you are searching for something similar to tex.stackexchange.com/a/385766/95441, right? Are you able to adjust this solution on your own?
â Stefan Pinnow
56 mins ago
Yes thanks a lot! I did see this post, maybe because I got to much focussed on putting "arrow" in my research... I came up with a solution thanks to you, I am going to post it
â jeannej
37 mins ago
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I use pfgplots
to draw two sets of data, stored in .dat
. Now I would like to automatically draw an arrow from one curve to the other, and only at the curves points. I tried to name the paths, but to no avail... Here is my minimum working example:
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
begindocument
begintikzpicture
%graphique
beginaxis
addplot[name path=c1,blue,thick,mark=*] plot table[x=a,y=b]data1.dat;
addplot[name path=c2,black,thick,mark=*] plot table[x=a,y=b]data2.dat;
%draw[red,->] (c1) -- (c2);
endaxis
endtikzpicture
enddocument
Which gives:
I would like to get (automatically from data points):
To generate this last picture I defined each arrow separately, for example for the last arrow: draw[red,-latex,thick,shorten >=0.1em] (3,1.5) -- (3,1.6);
I tryed to use the fillbetween
package to name the paths, but I have not been able to use it so far. Could I get something like : draw[red,->] (c1) -- (c2);
?
Thanks a lot for your help!
tikz-pgf pgfplots arrows tikz-datavisualization
I use pfgplots
to draw two sets of data, stored in .dat
. Now I would like to automatically draw an arrow from one curve to the other, and only at the curves points. I tried to name the paths, but to no avail... Here is my minimum working example:
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
begindocument
begintikzpicture
%graphique
beginaxis
addplot[name path=c1,blue,thick,mark=*] plot table[x=a,y=b]data1.dat;
addplot[name path=c2,black,thick,mark=*] plot table[x=a,y=b]data2.dat;
%draw[red,->] (c1) -- (c2);
endaxis
endtikzpicture
enddocument
Which gives:
I would like to get (automatically from data points):
To generate this last picture I defined each arrow separately, for example for the last arrow: draw[red,-latex,thick,shorten >=0.1em] (3,1.5) -- (3,1.6);
I tryed to use the fillbetween
package to name the paths, but I have not been able to use it so far. Could I get something like : draw[red,->] (c1) -- (c2);
?
Thanks a lot for your help!
tikz-pgf pgfplots arrows tikz-datavisualization
tikz-pgf pgfplots arrows tikz-datavisualization
asked 1 hour ago
jeannej
465
465
So you are searching for something similar to tex.stackexchange.com/a/385766/95441, right? Are you able to adjust this solution on your own?
â Stefan Pinnow
56 mins ago
Yes thanks a lot! I did see this post, maybe because I got to much focussed on putting "arrow" in my research... I came up with a solution thanks to you, I am going to post it
â jeannej
37 mins ago
add a comment |Â
So you are searching for something similar to tex.stackexchange.com/a/385766/95441, right? Are you able to adjust this solution on your own?
â Stefan Pinnow
56 mins ago
Yes thanks a lot! I did see this post, maybe because I got to much focussed on putting "arrow" in my research... I came up with a solution thanks to you, I am going to post it
â jeannej
37 mins ago
So you are searching for something similar to tex.stackexchange.com/a/385766/95441, right? Are you able to adjust this solution on your own?
â Stefan Pinnow
56 mins ago
So you are searching for something similar to tex.stackexchange.com/a/385766/95441, right? Are you able to adjust this solution on your own?
â Stefan Pinnow
56 mins ago
Yes thanks a lot! I did see this post, maybe because I got to much focussed on putting "arrow" in my research... I came up with a solution thanks to you, I am going to post it
â jeannej
37 mins ago
Yes thanks a lot! I did see this post, maybe because I got to much focussed on putting "arrow" in my research... I came up with a solution thanks to you, I am going to post it
â jeannej
37 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
Here is an alternative based on this nice answer. Its advantage is that it does not rely on the plot points having always the same distance. In fact, in your data set they don't, and that's the reason why in your answer the middle arrow is not vertical.
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
pgfplotsset
name nodes near coords/.style=
every node near coord/.append style=
name=#1-coordindex,
alias=#1-last,
,
,
name nodes near coords/.default=coordnode
begindocument
begintikzpicture
beginaxis[
nodes near coords=,nodes near coords style=anchor=center
]
addplot[blue,thick,mark=*, name nodes near coords=c]
table[x=a,y=b]data1.dat;
addplot+[black,thick,mark=*, name nodes near coords=d] table[x=a,y=b]data2.dat;
endaxis
foreach X in 0,...,2
draw[red,latex-latex] (c-X) -- (d-X);
endtikzpicture
enddocument
If you want the arrows to "touch" the plot marks, usenodes near coords style=anchor=center,inner sep=2pt
instead ofnodes near coords style=anchor=center
.
â marmot
16 mins ago
add a comment |Â
up vote
2
down vote
Thanks to this previous post, I came up with this solution.
documentclass[11pt]standalone
usepackagetikz,pgfplots
pgfplotssetcompat=newest
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
%reads data
pgfplotstablereaddata1.datdataA %beware that "data1" would trigger an error => do not use numbers
pgfplotstablegetrowsofdataA
pgfmathtruncatemacroNpgfplotsretval-1 %get access to the number of points in data
begindocument
begintikzpicture
%graphique
beginaxis
addplot[blue,thick,mark=*] plot table[x=a,y=b]data1.dat
foreach i in 0,...,N coordinate [pos=i/N] (ai);
addplot[black,thick,mark=*] plot table[x=a,y=b]data2.dat
foreach i in 0,...,N coordinate [pos=i/N] (bi);
endaxis
foreach i in 0,...,N
draw[red,-latex,thick,shorten >=0.1em] (ai) -- (bi);
endtikzpicture
enddocument
Which gives:
However you'll notice a slight shift of my middle arrow. I think this comes from my data not being evenly distributed... Would you have any insight on this ?
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
Here is an alternative based on this nice answer. Its advantage is that it does not rely on the plot points having always the same distance. In fact, in your data set they don't, and that's the reason why in your answer the middle arrow is not vertical.
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
pgfplotsset
name nodes near coords/.style=
every node near coord/.append style=
name=#1-coordindex,
alias=#1-last,
,
,
name nodes near coords/.default=coordnode
begindocument
begintikzpicture
beginaxis[
nodes near coords=,nodes near coords style=anchor=center
]
addplot[blue,thick,mark=*, name nodes near coords=c]
table[x=a,y=b]data1.dat;
addplot+[black,thick,mark=*, name nodes near coords=d] table[x=a,y=b]data2.dat;
endaxis
foreach X in 0,...,2
draw[red,latex-latex] (c-X) -- (d-X);
endtikzpicture
enddocument
If you want the arrows to "touch" the plot marks, usenodes near coords style=anchor=center,inner sep=2pt
instead ofnodes near coords style=anchor=center
.
â marmot
16 mins ago
add a comment |Â
up vote
3
down vote
Here is an alternative based on this nice answer. Its advantage is that it does not rely on the plot points having always the same distance. In fact, in your data set they don't, and that's the reason why in your answer the middle arrow is not vertical.
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
pgfplotsset
name nodes near coords/.style=
every node near coord/.append style=
name=#1-coordindex,
alias=#1-last,
,
,
name nodes near coords/.default=coordnode
begindocument
begintikzpicture
beginaxis[
nodes near coords=,nodes near coords style=anchor=center
]
addplot[blue,thick,mark=*, name nodes near coords=c]
table[x=a,y=b]data1.dat;
addplot+[black,thick,mark=*, name nodes near coords=d] table[x=a,y=b]data2.dat;
endaxis
foreach X in 0,...,2
draw[red,latex-latex] (c-X) -- (d-X);
endtikzpicture
enddocument
If you want the arrows to "touch" the plot marks, usenodes near coords style=anchor=center,inner sep=2pt
instead ofnodes near coords style=anchor=center
.
â marmot
16 mins ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Here is an alternative based on this nice answer. Its advantage is that it does not rely on the plot points having always the same distance. In fact, in your data set they don't, and that's the reason why in your answer the middle arrow is not vertical.
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
pgfplotsset
name nodes near coords/.style=
every node near coord/.append style=
name=#1-coordindex,
alias=#1-last,
,
,
name nodes near coords/.default=coordnode
begindocument
begintikzpicture
beginaxis[
nodes near coords=,nodes near coords style=anchor=center
]
addplot[blue,thick,mark=*, name nodes near coords=c]
table[x=a,y=b]data1.dat;
addplot+[black,thick,mark=*, name nodes near coords=d] table[x=a,y=b]data2.dat;
endaxis
foreach X in 0,...,2
draw[red,latex-latex] (c-X) -- (d-X);
endtikzpicture
enddocument
Here is an alternative based on this nice answer. Its advantage is that it does not rely on the plot points having always the same distance. In fact, in your data set they don't, and that's the reason why in your answer the middle arrow is not vertical.
documentclass[11pt]standalone
usepackagetikz,pgfplots,filecontents
pgfplotssetcompat=newest
usepgfplotslibraryfillbetween
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
pgfplotsset
name nodes near coords/.style=
every node near coord/.append style=
name=#1-coordindex,
alias=#1-last,
,
,
name nodes near coords/.default=coordnode
begindocument
begintikzpicture
beginaxis[
nodes near coords=,nodes near coords style=anchor=center
]
addplot[blue,thick,mark=*, name nodes near coords=c]
table[x=a,y=b]data1.dat;
addplot+[black,thick,mark=*, name nodes near coords=d] table[x=a,y=b]data2.dat;
endaxis
foreach X in 0,...,2
draw[red,latex-latex] (c-X) -- (d-X);
endtikzpicture
enddocument
answered 17 mins ago
marmot
72.4k477153
72.4k477153
If you want the arrows to "touch" the plot marks, usenodes near coords style=anchor=center,inner sep=2pt
instead ofnodes near coords style=anchor=center
.
â marmot
16 mins ago
add a comment |Â
If you want the arrows to "touch" the plot marks, usenodes near coords style=anchor=center,inner sep=2pt
instead ofnodes near coords style=anchor=center
.
â marmot
16 mins ago
If you want the arrows to "touch" the plot marks, use
nodes near coords style=anchor=center,inner sep=2pt
instead of nodes near coords style=anchor=center
.â marmot
16 mins ago
If you want the arrows to "touch" the plot marks, use
nodes near coords style=anchor=center,inner sep=2pt
instead of nodes near coords style=anchor=center
.â marmot
16 mins ago
add a comment |Â
up vote
2
down vote
Thanks to this previous post, I came up with this solution.
documentclass[11pt]standalone
usepackagetikz,pgfplots
pgfplotssetcompat=newest
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
%reads data
pgfplotstablereaddata1.datdataA %beware that "data1" would trigger an error => do not use numbers
pgfplotstablegetrowsofdataA
pgfmathtruncatemacroNpgfplotsretval-1 %get access to the number of points in data
begindocument
begintikzpicture
%graphique
beginaxis
addplot[blue,thick,mark=*] plot table[x=a,y=b]data1.dat
foreach i in 0,...,N coordinate [pos=i/N] (ai);
addplot[black,thick,mark=*] plot table[x=a,y=b]data2.dat
foreach i in 0,...,N coordinate [pos=i/N] (bi);
endaxis
foreach i in 0,...,N
draw[red,-latex,thick,shorten >=0.1em] (ai) -- (bi);
endtikzpicture
enddocument
Which gives:
However you'll notice a slight shift of my middle arrow. I think this comes from my data not being evenly distributed... Would you have any insight on this ?
add a comment |Â
up vote
2
down vote
Thanks to this previous post, I came up with this solution.
documentclass[11pt]standalone
usepackagetikz,pgfplots
pgfplotssetcompat=newest
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
%reads data
pgfplotstablereaddata1.datdataA %beware that "data1" would trigger an error => do not use numbers
pgfplotstablegetrowsofdataA
pgfmathtruncatemacroNpgfplotsretval-1 %get access to the number of points in data
begindocument
begintikzpicture
%graphique
beginaxis
addplot[blue,thick,mark=*] plot table[x=a,y=b]data1.dat
foreach i in 0,...,N coordinate [pos=i/N] (ai);
addplot[black,thick,mark=*] plot table[x=a,y=b]data2.dat
foreach i in 0,...,N coordinate [pos=i/N] (bi);
endaxis
foreach i in 0,...,N
draw[red,-latex,thick,shorten >=0.1em] (ai) -- (bi);
endtikzpicture
enddocument
Which gives:
However you'll notice a slight shift of my middle arrow. I think this comes from my data not being evenly distributed... Would you have any insight on this ?
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Thanks to this previous post, I came up with this solution.
documentclass[11pt]standalone
usepackagetikz,pgfplots
pgfplotssetcompat=newest
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
%reads data
pgfplotstablereaddata1.datdataA %beware that "data1" would trigger an error => do not use numbers
pgfplotstablegetrowsofdataA
pgfmathtruncatemacroNpgfplotsretval-1 %get access to the number of points in data
begindocument
begintikzpicture
%graphique
beginaxis
addplot[blue,thick,mark=*] plot table[x=a,y=b]data1.dat
foreach i in 0,...,N coordinate [pos=i/N] (ai);
addplot[black,thick,mark=*] plot table[x=a,y=b]data2.dat
foreach i in 0,...,N coordinate [pos=i/N] (bi);
endaxis
foreach i in 0,...,N
draw[red,-latex,thick,shorten >=0.1em] (ai) -- (bi);
endtikzpicture
enddocument
Which gives:
However you'll notice a slight shift of my middle arrow. I think this comes from my data not being evenly distributed... Would you have any insight on this ?
Thanks to this previous post, I came up with this solution.
documentclass[11pt]standalone
usepackagetikz,pgfplots
pgfplotssetcompat=newest
beginfilecontents*data1.dat
a b
1 1
2 1.2
3 1.5
endfilecontents*
beginfilecontents*data2.dat
a b
1 1.5
2 1.75
3 1.6
endfilecontents*
%reads data
pgfplotstablereaddata1.datdataA %beware that "data1" would trigger an error => do not use numbers
pgfplotstablegetrowsofdataA
pgfmathtruncatemacroNpgfplotsretval-1 %get access to the number of points in data
begindocument
begintikzpicture
%graphique
beginaxis
addplot[blue,thick,mark=*] plot table[x=a,y=b]data1.dat
foreach i in 0,...,N coordinate [pos=i/N] (ai);
addplot[black,thick,mark=*] plot table[x=a,y=b]data2.dat
foreach i in 0,...,N coordinate [pos=i/N] (bi);
endaxis
foreach i in 0,...,N
draw[red,-latex,thick,shorten >=0.1em] (ai) -- (bi);
endtikzpicture
enddocument
Which gives:
However you'll notice a slight shift of my middle arrow. I think this comes from my data not being evenly distributed... Would you have any insight on this ?
answered 27 mins ago
jeannej
465
465
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458871%2fdrawing-arrow-between-plots-table-datas%23new-answer', 'question_page');
);
Post as a guest
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
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
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
So you are searching for something similar to tex.stackexchange.com/a/385766/95441, right? Are you able to adjust this solution on your own?
â Stefan Pinnow
56 mins ago
Yes thanks a lot! I did see this post, maybe because I got to much focussed on putting "arrow" in my research... I came up with a solution thanks to you, I am going to post it
â jeannej
37 mins ago