0

I want to plot a vertical dotted red line in particular point (say 2.2) in xmgrace using script

1 Answers1

2

You can either use an external tool such as pygrace or use grace's built-in batch capabilities. These have been touched upon here on SO before (see, for instance, here or here).

The following script plots a datafile (exp.dat) as empty circles, another data file (line.dat) as a red dotted line and sets the ranges, labels and major ticks of the two axes:

READ NXY "exp.dat"
READ NXY "line.dat"

WORLD XMIN 0
WORLD XMAX 5
WORLD YMIN 1
WORLD YMAX 5
xaxis label "My x label"
xaxis tick major 1
yaxis label "My y label"
yaxis tick major 1

s0 line type 0
s0 symbol 1
s0 symbol size 1.5

s1 linestyle 2
s1 color 2

To generate a vertical red dotted line that passes through 2.2 the contents ofline.dat should be something like

2.2 0
2.2 10000

You can generate such a file in a bash script with the following command:

echo "2.2 0\n2.2 10000" > line.dat

Save the script as mybatch.xmg and call it like this:

xmgrace -batch mybatch.xmg

If you want to directly generate an output you can add this directive:

PRINT TO "myplot.eps"
DEVICE "EPS" OP "level2"
PRINT

which will save your plot as myplot.eps (add -nosafe when calling xmgrace to get rid of the warnings).

lr1985
  • 1,085
  • 1
  • 9
  • 21
  • thank you, but I have only one file and vertical red dotted line not plotted. The main problem is I want plot **some** dotted line in my graph. also want same color (black) data except dotted line. – Narender Bansal Mar 05 '20 at 04:23
  • It's not clear what you are asking. I think that my answer solves your problem, *as it is written now*. I have added a line on how to automatically generate the `line.dat` file in a bash script if that's what you were asking. – lr1985 Mar 05 '20 at 10:43