Are there guidelines for choosing colors in figures? Are there guidelines how to choose colors for figures in papers? I know that about 5-10% of the population see colors differently. How do I create a figure that has to have at least 4-5 different colors in it and make sure everyone will be able to see it and distinguish between the components.
The problem of different color perception (at least with respect to climate science) was pointed out 2004 by Light and Bartlein in EOS. With a strong emphasis on climate science the blog "Climate Lab Book" discusses the problem of the so called "rainbow color scale". As mentioned in the comments they recommend "Color brewer 2" to create color palettes. (There are packages for MATLAB, Python and R. The link to R includes some more advice.) Already pre-defined palettes (again with a strong emphasis on climate science) are presented by the Department of Geography of the University of Oregon. This palettes include color-blind safe ones, as well as palettes useful for specific associations.

For example when displaying temperatures blue is often associated with "cold", while red is associated with "hot". Diverting from similar common associations may prevent an more intuitive understanding of your figures.

Another reason for caution regarding color palettes: "Rainbow" (and similar ones) may distort your perception of boundaries.

To conclude: There appears no easy way to select an appropriate color palette for your figures, but there is plenty of advice.