1.2.6 Arrows

The following plot styles allow arrows or lines to be drawn on graphs with positions dictated by a series of datapoints:

The plot style of arrows is an alias for arrows_head. Each of these plot styles take four columns of data on two-dimensional plots – $x_1$, $y_1$, $x_2$ and $y_2$ – or six columns of data on three-dimensional plots with additional $z$-coordinates. Each datapoint results in an arrow being drawn from the point $(x_1,y_1,z_1)$ to the point $(x_2,y_2,z_2)$. The three plot styles differ in the kinds of arrows that they draw: arrows_head draws an arrow head on each arrow at the point $(x_2,y_2,z_2)$; arrows_nohead draws simple lines without arrow heads on either end; arrows_twohead draws arrow heads on both ends of each arrow.

A diagram of fluid flow around a vortex.

In this example we produce a velocity map of fluid circulating in a vortex. For simplicity, we assume that the fluid in the core of the vortex, at radii $r<1$, is undergoing solid body rotation with velocity $v\propto r$, and that the fluid outside this core is behaving as a free vortex with velocity $v\propto 1/r$. First of all, we use a simple python script to generate a datafile with the four columns:

from math import *
for i in range(-19,20,2):
for j in range(-19,20,2):
x = float(i)/2
y = float(j)/2
r = sqrt(x**2 + y**2) / 4
theta = atan2(y,x)
if (r $<$ 1.0): v = 1.3*r
else : v = 1.3/r
vy = v * cos(theta)
vx = v * -sin(theta)
print "%7.3f %7.3f %7.3f %7.3f"%(x,y,vx,vy)

This data can then be plotted using the following PyXPlot script:

set size square
set nokey
set xlabel ’x’
set ylabel ’y’
set trange [0:2*pi]
plot $\backslash $
’data’ u 1:2:($1+$3):($2+$4) w arrows, $\backslash $
parametric 4*sin(t):4*cos(t) w lt 2 col black

\includegraphics[width=10cm]{examples/eps/ex_vortex}