0

I have a datafile of following format (4 columns):

Size Xmid Ymid Angle

I want to plot line segments whose size is given in column 1, coordinates of the midpoint are given in columns 2 and 3, and angle with the x-axis is given in the last column.

How can I do that with gnuplot?

Lê Dũng
  • 113
  • 5

1 Answers1

1

You can use the vectors plot style. It requires the data to be supplied as x y xdelta ydelta, where x,y denote the coordinates of the line-segment origin, and xdelta/ydelta stand for the corresponding displacements to the end point. However, this can be easily calculated from your input:

#this specifies that Gnuplot will expect angles in degrees
set angles degrees

plot 'input.dat' \
  u ($2 - $1*cos($4)/2):($3 - $1*sin($4)/2):($1*cos($4)):($1*sin($4)) \
  w vectors nohead \
  lc rgb 'black' lw 2
ewcz
  • 12,819
  • 1
  • 25
  • 47