Today I will talk about Color Brewer, my most-used (free!) color selection tool. Depending on your audience and topic, there are a few things to be considered when selecting the colors for your figure. For example, if you are going to present your figures to the public, then it is important to use color-blind-friendly colors. To do that, there is a free tool, called Color Brewer and by using ColorBrewer, you can directly select color-blind-friendly color schemes.
Another thing I very much like about Color Brewer is that it allows you to choose between sequential, diverging, and qualitative color schemes. If you want to emphasize the group differences in the figure, then you can choose diverging colors. For example, if you present the effect of different treatments on a certain illness, and if you want to emphasize the differences between treatments, then you can choose diverging colors.
You can also decide on the number of groups you want to have when selecting a color scheme. Color Brewer allows you to choose between 3-12 groups which is a sufficient number I must say. Below, I chose a color-blind-friendly diverging color scheme with 5 categories and put the hex codes into the color list.
import numpy as np
import matplotlib.pyplot as plt
# dataset
height = [5, 15, 20, 28, 35]
variables = ('X1', 'X2', 'X3', 'X4', 'X5')
data = np.arange(len(variables))
# bars with different colors
plt.bar(data, height, color=['#f5f5f5', '#a6611a', '#80cdc1', '#018571', '#dfc27d'])
plt.xticks(data, variables)
plt.show()
If you had one type of variable with low and high values and you want to visualize it, you can go from, for example white (or very light green) to darker tones with sequential color schemes.
If you have categorical data without any magnitude differences and you do not specifically try to emphasize differences, then a qualitative color scheme is for you.
With ColorBrewer, it is also possible to choose print-friendly and photocopy-friendly color schemes depending on your purpose.
There are also other free color scheme tools such as Paletton, but ColorBrewer is what I found the handiest as I can select color-blind friendly, print-friendly options directly. If you want to explore more color options and be more artistic, Paletton can actually be better with its color wheel.
Enjoy the colors in your life!