Discussion:
How to produce screenplot and pslatex-plot with one batch file
(too old to reply)
h***@gmail.com
2021-07-08 14:30:46 UTC
Permalink
I currently use Gnuplot as follows:
I write a batch-file myfile.gp with the following commands in comment
#set terminal pslatex size 25cm,17cm monochrome
#set output "fileforlatex.tex"

I first run the batch file to see if plot is OK on screen, like this
gnuplot <myfile.gp --persist
If the result seems OK, I edit the original batch file and remove the #
such that I have:
set terminal pslatex size 25cm,17cm monochrome
set output "fileforlatex.tex"

The I rerun Gnuplot:
gnuplot <myfile.gp

I wonder whether it is possible to see the result on screen _and_ produce the fileforlatex.tex at the same time?

Here is a trivial example batch file: myfile.gp:
#set terminal pslatex size 25cm,17cm monochrome
#set output "fileforlatex.tex"
plot sin(x)
set output


kind regards,
Hugo
Gavin Buxton
2021-07-09 15:18:39 UTC
Permalink
Hi

I might be misunderstanding your question, but it seems like you want to see the output of your plot when the terminal is tex. I usually use ps or png files and then embed them in latex afterwards, so I would check it using something like:

set term post
set output 'temp.ps'
plot sin(x)
set output
!gv temp.ps

where the last command would open the file using ghostview (the exclamation mark just allows you to run external programs from gnuplot commandline). I don't use tex file directly, but I imagine to view the tex file you would need an external viewer of some kind?

Best


Gavin
h***@gmail.com
2021-07-10 09:23:43 UTC
Permalink
Post by Gavin Buxton
Hi
set term post
set output 'temp.ps'
plot sin(x)
set output
!gv temp.ps
where the last command would open the file using ghostview (the exclamation mark just allows you to run external programs from gnuplot commandline). I don't use tex file directly, but I imagine to view the tex file you would need an external viewer of some kind?
Best
Gavin
Dear Gavin,
Thanks for your answer but this is not what I want. I really want pslatex output as that gives nicer graphs than plain postscript. What I want is a default screen plot _and_ a pslatex-file all in one script.
Maybe someone else has a suggestion?

kind regards,
Hugo
Gavin Buxton
2021-07-10 15:07:25 UTC
Permalink
Ah, I think I see now. You could

set terminal pslatex size 25cm,17cm monochrome
set output "fileforlatex.tex"
plot sin(x)
set output
set term x11
rep

and just plot it again to the screen, but it might not look the same in a different terminal.
h***@gmail.com
2021-07-13 11:53:54 UTC
Permalink
Post by Gavin Buxton
Ah, I think I see now. You could
set terminal pslatex size 25cm,17cm monochrome
set output "fileforlatex.tex"
plot sin(x)
set output
set term x11
rep
and just plot it again to the screen, but it might not look the same in a different terminal.
Dear Gavin,
This is exactly what I needed. It makes my workflow a lot more efficient because when I see the plot looks OK on the screen I can now immediately start LaTeX, otherwise I always had to put those two lines in comment and rerun Gnuplot an extra time to produce the LaTeX picture.
Thanks a lot and kind regards,
Hugo

Loading...