mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.18k stars 1.89k forks source link

How to customize Palette in so.plot #3673

Closed z626093820 closed 2 months ago

z626093820 commented 3 months ago

The following is my code, I want to customize the COLOR_PALETTE, how should I modify the following two code and thank you in advance!

import seaborn.objects as so import seaborn as sns from seaborn import axes_style,plotting_context so.Plot.config.theme.update(plotting_context('paper',font_scale=1.4)|axes_style("ticks",rc={'axes.spines.top':False, 'axes.spines.right':False})) sns.set_palette(palette='Set1') p = so.Plot(dfupcub, 'AA', 'Fraction F',color="Codon").layout(size=(3, 3)) p.add(so.Bar(edgewidth=1), so.Stack())

When I use SNS.SET, it doesn't seem to work

import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import seaborn.objects as so sns.set('paper','ticks',font_scale=1.8,font='Arial',palette=sns.color_palette('Accent'),rc=({'svg.fonttype':'none'})) fig,ax=plt.subplots(figsize=(4,4)) sns.despine() p = so.Plot(dfupcub, 'AA', 'Fraction F',color="Codon") p.add(so.Bar(), so.Stack()).on(ax).plot()

thuiop commented 3 months ago

You need to use the .scale method. For the rest of the configuration it should be with .theme.