Gnuplottex: Pass latex command to gnuplot script
up vote
0
down vote
favorite
I want to access and plot the same data from different LaTeX documents (a paper and a beamer presentation) using gnuplottex. The data and the gnuplot script is stored at some individual position relative to the two documents. To re-use as much code as possible, I would like to define the relative path to the data in each document in a macro, here datapath.
My question is: How can I pass the value of this command to the gnuplot script? I would basically like to use the following in my MWE:
plot datapath'/data.csv' using 1:2 with lines
I did find this thread. However I was unable to modify it to my needs. Can someone help me, please?
MWE
documentclass{article}
usepackage[latin1]{inputenx}
usepackage{filecontents}
usepackage[
miktex, %
subfolder, % generated graphs in a ”gnuplottex” subfolder
cleanup, % Delete the .gnuplot files after conversion
]{gnuplottex}
newcommand{datapath}{./ZZZ}
begin{document}
% This is the data file to be plotted from
begin{filecontents*}{datapath/data.csv}
Col1,Col2
0,0
1,1
end{filecontents*}
% This is the gnuplot script I would like to use the value of datapath in
begin{filecontents*}{datapath/script.gnuplot}
set key autotitle columnhead
set datafile separator "," # for csv-file
plot './ZZZ/data.csv' using 1:2 with lines
end{filecontents*}
begin{figure}[htbp]
centering
gnuplotloadfile[terminal=cairolatex]{datapath/script.gnuplot}
end{figure}
end{document}
macros expansion external-files gnuplottex
add a comment |
up vote
0
down vote
favorite
I want to access and plot the same data from different LaTeX documents (a paper and a beamer presentation) using gnuplottex. The data and the gnuplot script is stored at some individual position relative to the two documents. To re-use as much code as possible, I would like to define the relative path to the data in each document in a macro, here datapath.
My question is: How can I pass the value of this command to the gnuplot script? I would basically like to use the following in my MWE:
plot datapath'/data.csv' using 1:2 with lines
I did find this thread. However I was unable to modify it to my needs. Can someone help me, please?
MWE
documentclass{article}
usepackage[latin1]{inputenx}
usepackage{filecontents}
usepackage[
miktex, %
subfolder, % generated graphs in a ”gnuplottex” subfolder
cleanup, % Delete the .gnuplot files after conversion
]{gnuplottex}
newcommand{datapath}{./ZZZ}
begin{document}
% This is the data file to be plotted from
begin{filecontents*}{datapath/data.csv}
Col1,Col2
0,0
1,1
end{filecontents*}
% This is the gnuplot script I would like to use the value of datapath in
begin{filecontents*}{datapath/script.gnuplot}
set key autotitle columnhead
set datafile separator "," # for csv-file
plot './ZZZ/data.csv' using 1:2 with lines
end{filecontents*}
begin{figure}[htbp]
centering
gnuplotloadfile[terminal=cairolatex]{datapath/script.gnuplot}
end{figure}
end{document}
macros expansion external-files gnuplottex
Your MWE works fine for me on Linux with pdflatex.
– Lars Kotthoff
Feb 15 at 17:22
Sure, it works great, no question. But I want to be able to useplot datapath'/data.csv' using 1:2 with linesinstead ofplot './ZZZ/data.csv' using 1:2 with lines. But how can I pass and expand the value ofdatapathinside the gnuplot document or store the content ofdatapathin a variable inside the gnuplot script as done in the post I linked to in my question?
– krtek
Feb 15 at 17:30
See stackoverflow.com/q/12328603/923955 I guess you need to dorenewcommand{gnuplotexe}{gnuplot -e "dirname=./ZZZ"}and usedirnamein the script file. I don't know about quoting, though, perhaps you don't need them.
– egreg
Feb 15 at 18:25
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to access and plot the same data from different LaTeX documents (a paper and a beamer presentation) using gnuplottex. The data and the gnuplot script is stored at some individual position relative to the two documents. To re-use as much code as possible, I would like to define the relative path to the data in each document in a macro, here datapath.
My question is: How can I pass the value of this command to the gnuplot script? I would basically like to use the following in my MWE:
plot datapath'/data.csv' using 1:2 with lines
I did find this thread. However I was unable to modify it to my needs. Can someone help me, please?
MWE
documentclass{article}
usepackage[latin1]{inputenx}
usepackage{filecontents}
usepackage[
miktex, %
subfolder, % generated graphs in a ”gnuplottex” subfolder
cleanup, % Delete the .gnuplot files after conversion
]{gnuplottex}
newcommand{datapath}{./ZZZ}
begin{document}
% This is the data file to be plotted from
begin{filecontents*}{datapath/data.csv}
Col1,Col2
0,0
1,1
end{filecontents*}
% This is the gnuplot script I would like to use the value of datapath in
begin{filecontents*}{datapath/script.gnuplot}
set key autotitle columnhead
set datafile separator "," # for csv-file
plot './ZZZ/data.csv' using 1:2 with lines
end{filecontents*}
begin{figure}[htbp]
centering
gnuplotloadfile[terminal=cairolatex]{datapath/script.gnuplot}
end{figure}
end{document}
macros expansion external-files gnuplottex
I want to access and plot the same data from different LaTeX documents (a paper and a beamer presentation) using gnuplottex. The data and the gnuplot script is stored at some individual position relative to the two documents. To re-use as much code as possible, I would like to define the relative path to the data in each document in a macro, here datapath.
My question is: How can I pass the value of this command to the gnuplot script? I would basically like to use the following in my MWE:
plot datapath'/data.csv' using 1:2 with lines
I did find this thread. However I was unable to modify it to my needs. Can someone help me, please?
MWE
documentclass{article}
usepackage[latin1]{inputenx}
usepackage{filecontents}
usepackage[
miktex, %
subfolder, % generated graphs in a ”gnuplottex” subfolder
cleanup, % Delete the .gnuplot files after conversion
]{gnuplottex}
newcommand{datapath}{./ZZZ}
begin{document}
% This is the data file to be plotted from
begin{filecontents*}{datapath/data.csv}
Col1,Col2
0,0
1,1
end{filecontents*}
% This is the gnuplot script I would like to use the value of datapath in
begin{filecontents*}{datapath/script.gnuplot}
set key autotitle columnhead
set datafile separator "," # for csv-file
plot './ZZZ/data.csv' using 1:2 with lines
end{filecontents*}
begin{figure}[htbp]
centering
gnuplotloadfile[terminal=cairolatex]{datapath/script.gnuplot}
end{figure}
end{document}
macros expansion external-files gnuplottex
macros expansion external-files gnuplottex
asked Feb 15 at 17:02
krtek
851720
851720
Your MWE works fine for me on Linux with pdflatex.
– Lars Kotthoff
Feb 15 at 17:22
Sure, it works great, no question. But I want to be able to useplot datapath'/data.csv' using 1:2 with linesinstead ofplot './ZZZ/data.csv' using 1:2 with lines. But how can I pass and expand the value ofdatapathinside the gnuplot document or store the content ofdatapathin a variable inside the gnuplot script as done in the post I linked to in my question?
– krtek
Feb 15 at 17:30
See stackoverflow.com/q/12328603/923955 I guess you need to dorenewcommand{gnuplotexe}{gnuplot -e "dirname=./ZZZ"}and usedirnamein the script file. I don't know about quoting, though, perhaps you don't need them.
– egreg
Feb 15 at 18:25
add a comment |
Your MWE works fine for me on Linux with pdflatex.
– Lars Kotthoff
Feb 15 at 17:22
Sure, it works great, no question. But I want to be able to useplot datapath'/data.csv' using 1:2 with linesinstead ofplot './ZZZ/data.csv' using 1:2 with lines. But how can I pass and expand the value ofdatapathinside the gnuplot document or store the content ofdatapathin a variable inside the gnuplot script as done in the post I linked to in my question?
– krtek
Feb 15 at 17:30
See stackoverflow.com/q/12328603/923955 I guess you need to dorenewcommand{gnuplotexe}{gnuplot -e "dirname=./ZZZ"}and usedirnamein the script file. I don't know about quoting, though, perhaps you don't need them.
– egreg
Feb 15 at 18:25
Your MWE works fine for me on Linux with pdflatex.
– Lars Kotthoff
Feb 15 at 17:22
Your MWE works fine for me on Linux with pdflatex.
– Lars Kotthoff
Feb 15 at 17:22
Sure, it works great, no question. But I want to be able to use
plot datapath'/data.csv' using 1:2 with lines instead of plot './ZZZ/data.csv' using 1:2 with lines. But how can I pass and expand the value of datapath inside the gnuplot document or store the content of datapath in a variable inside the gnuplot script as done in the post I linked to in my question?– krtek
Feb 15 at 17:30
Sure, it works great, no question. But I want to be able to use
plot datapath'/data.csv' using 1:2 with lines instead of plot './ZZZ/data.csv' using 1:2 with lines. But how can I pass and expand the value of datapath inside the gnuplot document or store the content of datapath in a variable inside the gnuplot script as done in the post I linked to in my question?– krtek
Feb 15 at 17:30
See stackoverflow.com/q/12328603/923955 I guess you need to do
renewcommand{gnuplotexe}{gnuplot -e "dirname=./ZZZ"} and use dirname in the script file. I don't know about quoting, though, perhaps you don't need them.– egreg
Feb 15 at 18:25
See stackoverflow.com/q/12328603/923955 I guess you need to do
renewcommand{gnuplotexe}{gnuplot -e "dirname=./ZZZ"} and use dirname in the script file. I don't know about quoting, though, perhaps you don't need them.– egreg
Feb 15 at 18:25
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can do it with immediatewrite instead of filecontents*:
newwritetempfile
immediateopenouttempfile=datapath/script.gnuplot
immediatewritetempfile{set key autotitle columnhead;
set datafile separator ",";
plot 'datapath/data.csv' using 1:2 with lines}
immediatecloseouttempfile
Thanks, but the data files and the gnuplot script exist as files at a defined location.filecontents*was only used here to provide a complete MWE.
– krtek
Feb 15 at 17:56
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variablesinside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.
– krtek
Feb 15 at 18:02
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can do it with immediatewrite instead of filecontents*:
newwritetempfile
immediateopenouttempfile=datapath/script.gnuplot
immediatewritetempfile{set key autotitle columnhead;
set datafile separator ",";
plot 'datapath/data.csv' using 1:2 with lines}
immediatecloseouttempfile
Thanks, but the data files and the gnuplot script exist as files at a defined location.filecontents*was only used here to provide a complete MWE.
– krtek
Feb 15 at 17:56
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variablesinside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.
– krtek
Feb 15 at 18:02
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
add a comment |
up vote
0
down vote
You can do it with immediatewrite instead of filecontents*:
newwritetempfile
immediateopenouttempfile=datapath/script.gnuplot
immediatewritetempfile{set key autotitle columnhead;
set datafile separator ",";
plot 'datapath/data.csv' using 1:2 with lines}
immediatecloseouttempfile
Thanks, but the data files and the gnuplot script exist as files at a defined location.filecontents*was only used here to provide a complete MWE.
– krtek
Feb 15 at 17:56
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variablesinside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.
– krtek
Feb 15 at 18:02
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
add a comment |
up vote
0
down vote
up vote
0
down vote
You can do it with immediatewrite instead of filecontents*:
newwritetempfile
immediateopenouttempfile=datapath/script.gnuplot
immediatewritetempfile{set key autotitle columnhead;
set datafile separator ",";
plot 'datapath/data.csv' using 1:2 with lines}
immediatecloseouttempfile
You can do it with immediatewrite instead of filecontents*:
newwritetempfile
immediateopenouttempfile=datapath/script.gnuplot
immediatewritetempfile{set key autotitle columnhead;
set datafile separator ",";
plot 'datapath/data.csv' using 1:2 with lines}
immediatecloseouttempfile
answered Feb 15 at 17:52
Lars Kotthoff
49836
49836
Thanks, but the data files and the gnuplot script exist as files at a defined location.filecontents*was only used here to provide a complete MWE.
– krtek
Feb 15 at 17:56
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variablesinside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.
– krtek
Feb 15 at 18:02
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
add a comment |
Thanks, but the data files and the gnuplot script exist as files at a defined location.filecontents*was only used here to provide a complete MWE.
– krtek
Feb 15 at 17:56
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variablesinside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.
– krtek
Feb 15 at 18:02
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
Thanks, but the data files and the gnuplot script exist as files at a defined location.
filecontents* was only used here to provide a complete MWE.– krtek
Feb 15 at 17:56
Thanks, but the data files and the gnuplot script exist as files at a defined location.
filecontents* was only used here to provide a complete MWE.– krtek
Feb 15 at 17:56
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
I guess then I don't understand your question. How are you going to pass the location of the data if you don't write it to the script file?
– Lars Kotthoff
Feb 15 at 17:58
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variable
s inside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.– krtek
Feb 15 at 18:02
That exactly is my question. In this post the value of the line color is stored in a macro and expanded into a variable
s inside the gnuplot script without writing it. So I guess it is possible. I just wasn't able to modify the approach to my problem. I always get the error that the files cannot be found.– krtek
Feb 15 at 18:02
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
This would require modifying the gnuplottex source code to read and replace a macro in the file.
– Lars Kotthoff
Feb 15 at 18:11
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f415496%2fgnuplottex-pass-latex-command-to-gnuplot-script%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
Your MWE works fine for me on Linux with pdflatex.
– Lars Kotthoff
Feb 15 at 17:22
Sure, it works great, no question. But I want to be able to use
plot datapath'/data.csv' using 1:2 with linesinstead ofplot './ZZZ/data.csv' using 1:2 with lines. But how can I pass and expand the value ofdatapathinside the gnuplot document or store the content ofdatapathin a variable inside the gnuplot script as done in the post I linked to in my question?– krtek
Feb 15 at 17:30
See stackoverflow.com/q/12328603/923955 I guess you need to do
renewcommand{gnuplotexe}{gnuplot -e "dirname=./ZZZ"}and usedirnamein the script file. I don't know about quoting, though, perhaps you don't need them.– egreg
Feb 15 at 18:25