The National Portrait Gallery is bringing together the works of two artistic visionaries exploring the complexities of identity in different eras