Since you mention the t (min) column in the hue option, you need to know the total number of unique values of the column.
Assume that there are 5 unique values in the column. You, thus, can set the number to the n_colors option of sns.color_palette:
ax = sns.lineplot(x="Wavelength",
y="Absorption",
hue="t (min)",
lw=1,
data=df1,
palette=sns.color_palette('coolwarm', n_colors=5),
legend="brief")
Answer from Hakan Özler on Stack OverflowSince you mention the t (min) column in the hue option, you need to know the total number of unique values of the column.
Assume that there are 5 unique values in the column. You, thus, can set the number to the n_colors option of sns.color_palette:
ax = sns.lineplot(x="Wavelength",
y="Absorption",
hue="t (min)",
lw=1,
data=df1,
palette=sns.color_palette('coolwarm', n_colors=5),
legend="brief")
No need to worry about the color count if you set your color palette as a color map by setting "as_cmap" argument to True in sns.color_palette:
ax = sns.lineplot(x="Wavelength",
y="Absorption",
hue="t (min)",
lw=1,
data=df1,
palette=sns.color_palette('coolwarm', as_cmap = True),
legend="brief")
Cycle through colors if not enough colors in palette
python - How can I resolve "UserWarning: The palette list has more values (10) than needed (4), which may not be intended"? - Stack Overflow
Newest 'palette' Questions - Stack Overflow
I'm having issues creating multiple color palettes with PIL
Running https://theouterlinux.gitlab.io/website/Downloads/img2qb.py (should just open as text in your browser) gives me the following error:
Traceback (most recent call last): File "/path/to/img2qb.py", line 117, in <module> resim.putpalette(palette256) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1488, in putpalette self.load() # install new palette File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 763, in load self.im.putpalette(*self.palette.getdata()) ValueError: invalid palette size
This is the part of the script in which a 256 color palette is supposed to be created using a long (or soon to be) list of RGB color values. However, at 36 colors, I stopped to test it out before devoting any more time to adding colors just to make sure everything would run ok. It doesn't. But, I have no idea why since a 16-color palette is created (~ line 47) without any issues just before the attempt at the 256 (or only 36 at this point) version using the same code except for the value of the 'entries' variable.
I'm creating an image to QuickBasic DATA (QB45, QBX, and QB64) format converter to run using both Python 2.7 and 3 just in case anyone was curious. Though, besides the error above, I have no idea how Windows friendly it is as I fortunately haven't had to mess with it in many many years.
It is quite simple as per the official docs. Just set n_colors to be more than the number of colors in the palette. Below is the relevant information (highlighted in bold). Here you can just set n_colors to a large number. Anything more than 2 will work in your case.
n_colors : int, optional Number of colors in the palette. If
None, the default will depend on howpaletteis specified. Named palettes default to 6 colors, but grabbing the current palette or passing in a list of colors will not change the number of colors unless this is specified. Asking for more colors than exist in the palette will cause it to cycle.
import seaborn as sns
sns.set_palette(['#000000', '#ABABAB'], n_colors=100)
sns.barplot([1, 2, 3], [4, 5, 6])
EDIT It seems that one has to have to n_colors also more than the number of patches (bars in this case). So if there are two colors in the palette and 4 patches, then n_colors should be also more than both (>4 in this case).

In newer Seaborn versions (≥ 0.13) if hue is not set, Seaborn no longer cycles colors across bars (see Changes to color defaults). Also note that I added x= and y= since no positional arguments are allowed since version 0.11. So the code
sns.set_palette(['#000000', '#ABABAB'])
sns.barplot(x=[1, 2, 3], y=[4, 5, 6])
plots

To get the desired effect, use hue:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_palette(['#000000', '#ABABAB'])
# Removed the incorrect hue argument
sns.barplot(x=[1, 2, 3], y=[4, 5, 6], hue=[1, 2, 3], legend=False, palette=['#000000', '#ABABAB'])
plt.show()
plt.savefig("barplot.png")

Since the palette contains only two colors and there are three bars/three hue levels, Seaborn will issue a warning:
The palette list has fewer values (2) than needed (3) and will cycle, which may produce an uninterpretable plot.
See also my answer to a similar question.
I took a picture and made a color palette out of it. I also thought it would be interesting to use a "negative" filter on the text so I know the contrast is always 100% compared to the background.
In theory, the text should be super lisible, but it's clearly not. Also, I would have thought a color palette made with colours and their opposite would be interesting, but now I'm not so sure. What do you think?