# How to produce screenplot and pslatex-plot with one batch file

21 views
Skip to first unread message

### hugoc...@gmail.com

unread,
Jul 8, 2021, 10:30:48 AM7/8/21
to
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

unread,
Jul 9, 2021, 11:18:40 AM7/9/21
to
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

### hugoc...@gmail.com

unread,
Jul 10, 2021, 5:23:44 AM7/10/21
to
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

unread,
Jul 10, 2021, 11:07:26 AM7/10/21
to
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.

### hugoc...@gmail.com

unread,
Jul 13, 2021, 7:53:55 AM7/13/21
to
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
Reply all
Reply to author
Forward
0 new messages