write functions for principal components and legend