A MetaPost way of doing this:
prologues := 3;
outputtemplate := "%j-%c.mps";
input latexmp; setupLaTeXMP(options = "12pt", textextlabel = enable, mode = rerun);
% t[] values on top, b[] values on bottom
% u spacing between columns, v arrows length
vardef corresp(suffix t, b)(expr u, v) =
save i; numeric i; i = 1;
forever:
exitif (unknown t[i]) or (unknown b[i]);
drawdblarrow ((i-1)*u, 0) -- ((i-1)*u, v);
label.top("$" & decimal t[i] & "$", ((i-1)*u, v));
label.bot("$" & decimal b[i] & "$", ((i-1)*u, 0));
i := i+1;
endfor
enddef;
% The OP's example
beginfig(1);
numeric u, v, t[], b[]; u = 0.75cm; v = 0.75cm;
for i = 1 upto 3: b[i] = i-1; t[i] = i; endfor
corresp(t, b)(u, v);
endfig;
% A bigger example
beginfig(2);
numeric u, v, t[], b[]; u = cm; v = cm;
for i = 1 upto 7: t[i] = i-1; b[i] = (i-1)**2; endfor
corresp(t, b)(u, v);
endfig;
end.
Horizontal spacing u
between numbers can be adjusted at will, as for the arrows length v
. As many numbers as wished at the top and the bottom can be entered, respectively in the arrays t[]
and b[]
. The corresp
macro takes care of the subsequent job.
The code is supposed to be compiled by MetaPost with LaTeX as typesetting engine.
mpost --tex=latex program.mp
Two figures are produced by this code: The first one is the OP's example, the second one is another (bigger) example.

