In his austere use of color and sometimes doleful subject matter – prostitutes and beggars are frequent subjects – Picasso was influenced by a trip through Spain and by the suicide of his friend Carlos Casagemas .