fix plotkm when there are more than 2 levels of the group