  We study soliton solutions of matrix Kadomtsev-Petviashvili (KP) equations in
a tropical limit, in which their support at fixed time is a planar graph and
polarizations are attached to its constituting lines. There is a subclass of
"pure line soliton solutions" for which we find that, in this limit, the
distribution of polarizations is fully determined by a Yang-Baxter map. For a
vector KP equation, this map is given by an R-matrix, whereas it is a
non-linear map in case of a more general matrix KP equation. We also consider
the corresponding Korteweg-deVries (KdV) reduction. Furthermore, exploiting the
fine structure of soliton interactions in the tropical limit, we obtain a new
solution of the tetrahedron (or Zamolodchikov) equation. Moreover, a solution
of the functional tetrahedron equation arises from the parameter-dependence of
the vector KP R-matrix.
