【2.1.1】柱状图(seaborn-barplot)

四、我的案例

4.1 自定义bar的颜色

import pandas as pd 
import matplotlib.pyplot as plt
import seaborn as sns

df_all = df_3

fig = plt.figure(figsize=(16, 10), dpi= 80)

custom_palette = ["red", "blue", "green"] # 这里定义的颜色和hue对应
ax = sns.barplot(data=df_all, x="protein", y="expression",hue="Note", palette=custom_palette) # 


ax.legend(loc='upper center', shadow=True, fontsize='20')

plt.xlabel('', size=30)
plt.ylabel('In vitro expression of A549', size=30)
plt.xticks(fontsize=25) #,rotation=45
plt.yticks(fontsize=25)
药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn