2

I am trying to create a bar plot with 11 different colors.

ax = sns.barplot(x=newx, y=newy, palette=sns.color_palette("Set2", n_colors=len(pairs)))

But I am getting only 8 different colors, and the last 3 bars repeating
the colors of the first 3 bars.
The pairs length is 11. The same result I am getting with Set1.

LetzerWille
  • 5,355
  • 4
  • 23
  • 26

1 Answers1

2

You are using and choosing color palettes with a discrete number of colors less than 11, therefore it is repeating color assignment.

https://python-graph-gallery.com/197-available-color-palettes-with-matplotlib/

Click "Discrete" tab (See number of descrete colors for those palettes).

Try choosing a different color palette from 'Sequential' or 'Diverging' tabs to get more color division options. For example choosing 'Spectral' with 11 division yeilds the following colors.

sns.palplot(sns.color_palette('Spectral',11))

Output: enter image description here

Scott Boston
  • 147,308
  • 15
  • 139
  • 187