seaborn cycle through colours with matplotlib scatter

后端 未结 2 1427
说谎
说谎 2020-12-28 15:06

How can I get seaborn colors when doing a scatter plot?

import matplotlib.pyplot as plt
import seaborn as sns
ax=fig.add_subplot(111)
for f in files:
    ax.         


        
2条回答
  •  梦毁少年i
    2020-12-28 15:18

    To build on Carsten's answer, if you have a large number of categories to assign colours to, you might wish to zip the colours to a very large seaborn palette, for example the xkcd_palette or crayon_palette.. Note that this practice is usually a chartjunk anti-pattern: using more than 5-6 colours is usually overkill, and you might need to consider changing your chart type.

    import matplotlib.pyplot as plt
    import seaborn as sns
    
    palette = zip(df['category'].unique(), sns.crayons.values())
    

提交回复
热议问题