import os DATAFILE='xrddata.dat' PLOTFILE='xrddata.png' LOWER=35 UPPER=36.5 f=os.popen('gnuplot' ,'w') print >>f, "set xrange [%f:%f]" % (LOWER,UPPER) print >>f, "set xlabel 'Diffraction angle'; set ylabel 'Counts [a.u.]'" print >>f, "plot '%s' using 1:2:(sqrt($2)) with errorbars title 'XRPD data' lw 3" % DATAFILE print >>f, "set terminal png large transparent size 600,400; set out '%s'" % PLOTFILE print >>f, "pause 2; replot" f.flush()