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.
Different screens may display colors differently due to different color curves (or even display settings). And colors don't scale linearly on most screens, so you can't just use RGB values (not to mention RGB is a poor color space in relation to human perception). Just because it displays well on your screen doesn't mean that it will display the same way for everyone else, regardless of disability. The other issue is that some people print out papers, and may not use color.
To help reduce these problems, you should use a contrast checker. If you have to choose between 4-5 colors, pick colors that each differ enough on this color checker. There are also established standards at least in the web development community, but they should be reasonable that they apply to this as well. Among these guidelines are color contrast requirements.
There are alternatives to using colors to differentiate though. You could also use different shapes or different border designs, etc. Preferably, you could use these in addition to smart color selection, but if your colors have poor contrast, then these can help to further distinguish the various elements in the figure.
Just from personal preference, but colored text (not white or black) almost always looks bad because the characters end up being pretty narrow, and subpixel coloring to avoid anti-aliasing doesn't help here.