通过在seaborn的plot方法中对其 palette 参数进行调色盘设置即可
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import seaborn as sns
# 初始化画板
def initPlot():
sns.set(style="whitegrid", palette="muted",
color_codes=True, font='SimHei') # set( )设置主题,调色板更常用
# mpl.rcParams['font.family'] = 'SimHei'
plt.rcParams['axes.unicode_minus'] = False # 解决坐标轴负数的负号显示问题
initPlot()
df_A = readData() # 读取excel数据
plt.figure(figsize=(50,10)) # 扩大行间距
sns.countplot(x="颜色", hue="表面风化", data=df_A,
palette=sns.color_palette("BuGn_r", 2))
plt.show()
效果如下