Hi Weiyuan,
> I want to consider a system with spin, so the hopping is a matrix. How to
> change the the kwant code to plot the eigenvectors of system that spin is
> considered.
The short answer is that you can't do it using `kwant.map`. `kwant.map`
plots a _scalar_ field defined over sites, whereas your wavefunction
with spin degree of freedom is a _spinor_ field over sites. If you
just want to plot, say, the spin up / down _components_ of the
(absolute squared) wavefunction this is certainly possible:
evecs = la.eigh(ham)[1]
wf_up = np.abs(evecs[::2, n])**2
wf_down = np.abs(evecs[1::2, n])**2
...
The degrees of freedom in the wavefunction are ordered first by site,
and then by internal degree of freedom. Assuming that all your sites
have the 2x2 matrix structure, this means that all the even-numbered
degrees of freedom are the spin-up ones and the odd-numbered are
the spin-down ones. The slices `::2` and `1::2` in the above snippet
allow us to access these two parts of the wavefunction array.
Hope that helps,
Joe