You have to convert a list of colors from seaborn palette to color map of matplolib (thx to @RafaelLopes for proposed changes):
import seaborn as sns
import matplotlib.pylab as plt
import numpy as np
from matplotlib.colors import ListedColormap
# construct cmap
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
my_cmap = ListedColormap(sns.color_palette(flatui).as_hex())
N = 500
data1 = np.random.randn(N)
data2 = np.random.randn(N)
colors = np.linspace(0,1,N)
plt.scatter(data1, data2, c=colors, cmap=my_cmap)
plt.colorbar()
plt.show()

python - seaborn color_palette as matplotlib colormap - Stack Overflow
Creating Custom Seaborn Color Palettes from ONLY two Hex Codes? [Question]
`sns.color_palette(as_cmap= True)` returns no cmap
python - How to set matplotlib colormap as color palette in seaborn - Stack Overflow
You have to convert a list of colors from seaborn palette to color map of matplolib (thx to @RafaelLopes for proposed changes):
import seaborn as sns
import matplotlib.pylab as plt
import numpy as np
from matplotlib.colors import ListedColormap
# construct cmap
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
my_cmap = ListedColormap(sns.color_palette(flatui).as_hex())
N = 500
data1 = np.random.randn(N)
data2 = np.random.randn(N)
colors = np.linspace(0,1,N)
plt.scatter(data1, data2, c=colors, cmap=my_cmap)
plt.colorbar()
plt.show()

Most seaborn methods to generate color palettes have an optional argument as_cmap which by default is False. You can use to directly get a Matplotlib colormap:
import seaborn as sns
import matplotlib.pylab as plt
import numpy as np
# construct cmap
my_cmap = sns.light_palette("Navy", as_cmap=True)
N = 500
data1 = np.random.randn(N)
data2 = np.random.randn(N)
colors = np.linspace(0,1,N)
plt.scatter(data1, data2, c=colors, cmap=my_cmap)
plt.colorbar()
plt.show()

Hi,
I am wondering if it is possible to create custom diverging seaborn color palettes by only giving it the starting and end colors.
So as an example, If I wanted Hex Code '#3877C7' to be the negative value and '#C75B38' to be the positive, is there a way to tell seaborn (or anything) this and have it automatically fill in the rest of the colors?
I know you can create custom palettes if you list off every combo you want, but that seems very manual if you are changing the two end colors often.
Thanks!
