I am currently using color shades from single color matplotlib colormaps (like Blues
, Purples
, Greens
). However I would prefer softer, "pastel" tones. How could I soften the existing colormaps or perhaps there are more appropriate colormaps to use for this purpose?
Remark: my question is essentially a python version of this one: R convert colors to pastel colors .
After some research I have adopted the solution used by painters to obtain pastel colors: mixing the color with white paint. In pythonic terms, if I want to chose, eg, n
shades of blue, I take
n = 15
colors = (1. - c) * plt.get_cmap("Blues_r")(np.linspace(0., 1., n)) + c * np.ones((n, 4))
plt.scatter(np.arange(n),np.ones(n), c=colors, s=180)
plt.show()
where c
controls the degree of "softness/pastelness". Thus, for c=0
the pure color is
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.