From 066edd3c30463a6c7c3a2161d204ee4101931be6 Mon Sep 17 00:00:00 2001 From: Tommaso Cucinotta Date: Mon, 17 Oct 2016 08:44:16 +0200 Subject: [PATCH] Enable graphics generation from external gnuplot scripts. --- lib/Makefile.am | 1 + lib/configure.py | 5 ++++- lib/scripts/gnuplot2pdf.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 lib/scripts/gnuplot2pdf.py diff --git a/lib/Makefile.am b/lib/Makefile.am index 66fe0516e9..fc578a59d4 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2332,6 +2332,7 @@ dist_scripts_DATA += \ scripts/svg2pdftex.py \ scripts/svg2pstex.py \ scripts/fig_copy.py \ + scripts/gnuplot2pdf.py \ scripts/html2latexwrapper.py \ scripts/include_bib.py \ scripts/layout2layout.py \ diff --git a/lib/configure.py b/lib/configure.py index f995c62ca7..59f89f67db 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1045,7 +1045,10 @@ def checkConverterEntries(): rc_entry = [ r'''\converter svg png "%%" "", \converter svgz png "%%" ""'''], path = ['', inkscape_path]) - + # + checkProg('Gnuplot', ['gnuplot'], + rc_entry = [ r'''\Format gnuplot "gp, gnuplot" "Gnuplot" "" "" "" "vector" "text/plain" +\converter gnuplot pdf6 "python -tt $$s/scripts/gnuplot2pdf.py $$i $$o" ""''' ]) # # gnumeric/xls/ods to tex checkProg('a spreadsheet -> latex converter', ['ssconvert'], diff --git a/lib/scripts/gnuplot2pdf.py b/lib/scripts/gnuplot2pdf.py new file mode 100755 index 0000000000..fb036b2df5 --- /dev/null +++ b/lib/scripts/gnuplot2pdf.py @@ -0,0 +1,17 @@ +#!/usr/bin/python + +from subprocess import Popen, PIPE +from sys import argv, stderr, exit +import os +import shutil + +if (len(argv) != 3): + stderr.write("Usage: %s \n" % argv[0]) + exit(1) + +with open(argv[1], 'rb') as fsrc: + subproc = Popen("gnuplot", shell=True, stdin=PIPE) + subproc.stdin.write("set terminal pdf\nset output '%s'\n" % argv[2]) + shutil.copyfileobj(fsrc, subproc.stdin) + subproc.stdin.write("exit\n") + subproc.wait() -- 2.39.2