Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
708 views
in Technique[技术] by (71.8m points)

plot - How to use batch script with xmgrace

I am trying to use a batch script to plot data with xmgrace. However, I have encountered major problems in trying to find documentation on how to do this. I am trying to produce a panel plot, with graphs looking like this:

enter image description here

I am having problems with three things in doing so:

1) I want to be able to specify the limits of the x- and y-axis for each graph in the panel plot (or even better for all graphs at the same time) and I haven't found how to do this.

2) The data is stored in six columns in two different files. The x-values are in column 1 for both files. I would like to be able to import the data with a similar syntax as in gnuplot where I'd use

plot 'file.dat' using 1:(2.0*$3)

to plot column 3 against column 1, and multiply the values in column 3 by 2.0. The important thing here is that I need to multiply some of the columns in one of the files with 2.0 to compare them with the content of the other file in a comprehensible way. I would also prefer a syntax where I can import the columns one at a time, instead of using

READ NXY "file.dat"

where it reads all columns and I have to KILL the ones I don't want.

3) How do I change the dimensions of the graph? Changing the dimensions of the canvas using

PAGE SIZE width, height

doesn't change the dimensions of the graph, or it does but not to fill the canvas. The default size for a panel plot with 4 by 2 graphs (which is what I want) does not show enough detail.

I have found this page to be somewhat helpful: http://ringo.ams.sunysb.edu/index.php/Xmgrace

but it does not contain examples of everything I need to do.

So far, my batch script looks like:

# make a panel plot
arrange (1,1,.1,.2,.5,ON,OFF,OFF)
# chose the first panel
FOCUS G0
# I was hoping this line would allow me to change the axis limits, but it isn't working:
world 0, -1, 20, 1
#each file has 6 columns
#s0 to s4
READ NXY "file2.dat"
#s5 to s9
READ NXY "file1.dat"
s0 line color 1
s1 line color 2
s2 line color 3
s3 line color 4
#s5 and s6 need to be multiplied by 2.0
s5 line color 1
s5 linestyle 4
s6 line color 2
s6 linestyle 4
s7 line color 3
s7 linestyle 4
s8 line color 4
s8 linestyle 4
s9 line color 5
KILL G0.s4
xaxis label "time"
xaxis tick place normal
yaxis label "density"
PAGE SIZE 2500, 2000

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

1) To specify the limits of the x- and y-axis for all graphs at the same time, use the following commands.

WORLD XMIN 0
WORLD XMAX 20
WORLD YMIN -2
WORLD YMAX 2

and optionally specify the ticks (major and minor) along x-axis as

XAXIS TICK MAJOR 0.5
XAXIS TICK MINOR 0.25

2) The syntax to import the columns one at a time is

READ BLOCK "file2.dat"
BLOCK xy "1:2"
BLOCK xy "1:3"
BLOCK xy "1:4"
BLOCK xy "1:5"
READ BLOCK "file2.dat"
BLOCK xy "1:2"
BLOCK xy "1:3"
BLOCK xy "1:4"
BLOCK xy "1:5"
BLOCK xy "1:6"

To perform algebraic operations with specific columns, such as multiplying columns 2 and 3 of "file.dat" with 2, you can use

s4.y = 2*s4.y
s5.y = 2*s5.y

Note that as additional blocks of data are read in, newer sets with incremental suffixes are created, such as s0, s1, s2, ..... Since column 6 of file2.dat is not read, the sets are numbered differently here relative to the original script.

3) To change dimensions of a graph (say G0)

FOCUS G0;
VIEW 0.15, 0.15, 0.15, 0.85

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...