mailA tip for converting the result directories xmgrace files to eps and png


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Troels Emtekær Linnet on June 13, 2013 - 14:32:
Hi.

I got tired of opening each xmgrace file to see the plot.
I found that to export to png, you need to:

Add this to the end of the xmgrace file

#Print out to
@PRINT TO "/home/you/output.png"
@HARDCOPY DEVICE "PNG"
@DEVICE "PNG" FONT ANTIALIASING on
# Make white background transparent
#@DEVICE "PNG" OP "transparent:on"
@DEVICE "PNG" OP "compression:9"
@PRINT

Then issue an "HARDCOPY" with xmgrace
xmgrace -hardcopy xmgracefile.agr


Script to make both png and eps for a folder with xmgrace files

Write in: xmgrace_png
and put in your bin folder

#!/bin/bash

for gracefile in *.agr; do
filename=$(basename "$gracefile")
extension="${filename##*.}"
filename="${filename%.*}"

TMPPNG=${filename}_png.tmp
cat $gracefile > $TMPPNG
echo "#Print out to" >> $TMPPNG
echo '@PRINT TO "'"${PWD}/${filename}.png"'"' >> $TMPPNG
echo '@HARDCOPY DEVICE "PNG"' >> $TMPPNG
echo '@DEVICE "PNG" FONT ANTIALIASING on' >> $TMPPNG
echo '# Make white background transparent' >> $TMPPNG
echo '#@DEVICE "PNG" OP "transparent:on"' >> $TMPPNG
echo '@DEVICE "PNG" OP "compression:9"' >> $TMPPNG
echo '@PRINT' >> $TMPPNG
xmgrace -hardcopy $TMPPNG

TMPEPS=${filename}_eps.tmp
cat $gracefile > $TMPEPS
echo "#Print out to" >> $TMPEPS
echo '@PRINT TO "'"${PWD}/${filename}.eps"'"' >> $TMPEPS
echo '@HARDCOPY DEVICE "EPS"' >> $TMPEPS
echo '@DEVICE "EPS" OP "level2"' >> $TMPEPS
echo '@PRINT' >> $TMPEPS
xmgrace -hardcopy $TMPEPS

echo "$filename $extension"
#eps2png -resolution 200 $TMPEPS
#epstopdf $TMPEPS
done

Then just make "chmod +x xmgrace_png
and in the folder, issue an:

xmgrace_png

sit back and relax

If you want to convert eps to pdf

bash ;
for epsfile in *.eps; epstopdf $epsfile; echo "Making pdf: $epsfile"; done

Troels Emtekær Linnet



Related Messages


Powered by MHonArc, Updated Mon Jun 24 22:20:05 2013