xsize=21
ysize=24
size xsize ysize

pt=0.0352777778 ! 1 postscript point

! funky LaTeX commands
begin texpreamble
    % set fonts used for text and maths to Palatino
    \usepackage{mathpazo}
    \renewcommand{\familydefault}{ppl}
    \usepackage{upgreek}
    \usepackage{bm}
end texpreamble

! set the normal font to AvantGarde-Demi, which is really obviously
! different to Palatino, so you can spot it if you forget to wrap
! text in \tex{}
set font psagd

set hei 12*pt

arrowwidth=0.5*pt
set arrowsize 3*pt
set just cc

linelength=5*pt
gridsize=0.25
radius=13

infinity=25
centrex=14.1
centrey=15

set lwidth arrowwidth
for x = -infinity to infinity
    for y = -infinity to infinity
        r = sqrt(x^2 + y^2)
        if (r > radius+1) or (centrex+x*gridsize > xsize) then
            col = (r-radius-2)/(infinity-radius)
            set color rgb(col,col,col)
            amove centrex centrey
            rmove x*gridsize y*gridsize-linelength/2
            rline 0 linelength arrow end
        end if
    next y
next x

set color rgb(0.8,0.8,1)
set lwidth 2*pt
set lstyle 9
amove centrex centrey
circle (radius+0.5)*gridsize

centrex=3.5
centrey=20.5

set color black
set lwidth arrowwidth
set lstyle 1
for x = -radius to radius
    for y = -radius to radius
        if sqrt(x^2 + y^2) <= radius then
            amove centrex centrey
            rmove x*gridsize y*gridsize-linelength/2
            rline 0 linelength arrow end
        end if
    next y
next x


set color rgb(0.8,0.8,1)
set lwidth 2*pt
set lstyle 9
amove centrex centrey
circle (radius+0.5)*gridsize

set lwidth arrowwidth
set lstyle 1
set color black
amove 0.5 7.5
for x = -infinity to infinity
    rmove gridsize -linelength
    rline 0 linelength arrow end
next x

amove 0.5 1
for x = -infinity to infinity
    rmove gridsize -linelength
    rline 0 linelength arrow end
next x

set color rgb255(255,13,13)
amove 0.5 7.75
for x = 0 to infinity-1
    rmove gridsize*2 0
    text \tex{$+$}
next x

set color rgb255(48,80,248)
amove 0.5 0.6
for x = 0 to infinity-1
    rmove gridsize*2 0
    text \tex{$-$}
next x

! big magnetisation arrow
set lwidth 1
set arrowsize 1
amove 15 2
rline 0 5 arrow end
set color white
rmove 0 -3
text \tex{$\bm{M}$}

! big demag field arrows
set color rgb255(144,224,80)
amove 1.75 7
rline 0 -5.5 arrow end
amove 5.25 7
rline 0 -5.5 arrow end
amove 8.75 7
rmove 0 -2.5
set color black
begin rotate 270
 tex "$\bm{B}_{\mathrm{demag}}$"
end rotate
rmove 0 2.5
set color rgb255(144,224,80)
rline 0 -5.5 arrow end
amove 12.25 7
rline 0 -5.5 arrow end

! big Lorentz field arrow
amove 14 12.6
rline 0 5 arrow end
rmove 0 -3
set color black
begin rotate 90
 tex "$\bm{B}_{\mathrm{L}}$"
end rotate

! tiny Lorentz sphere at centre of demag pic
set color rgb(0.8,0.8,1)
set lwidth 1*pt
set lstyle 9
amove 7 4.3
circle 0.7

! a,b,c
set color black
amove 6.5 23
tex "(a)"
amove 7 16
tex "(b)"
amove 1 8.5
tex "(c)"