import pandas as pd
import matplotlib.pyplot as plt
from pandas import Series,DataFrame
import numpy as np
from pylab import mpl
# df = pd.read_excel('f://Research/2020/Xionjianli/Data/季节差异显著_genus1.xls',sheet_name)
#修改字体大小及其格式
plt.rc('font',family='Times New Roman')
mpl.rcParams['font.size']=16
#读取EXCEL表格
df = pd.read_excel('F://Research/2020/Xionjianli/Data/季节差异显著_genus1.xls',sheet_name='Sheet2')
#提取数据
ck=df['CKJWD-Sd(%)']/pow(15,1/2)#计算标准误
cq=df['CQKWD-Sd(%)']/pow(15,1/2)
#画图
plt.figure(figsize=(8,4),dpi=300)#定义画布
plt.barh(df.index+0.4,df['Withering'],height=0.4,xerr=ck,error_kw = {
'ecolor' : '0.2', 'capsize' :2},label='Withering',color='r',edgecolor='black')#画横向柱状图
plt.barh(df.index,df['Grassy'],height=0.4,xerr=cq,error_kw = {
'ecolor' : '0.2', 'capsize' :2},label='Grassy',color='mediumblue',edgecolor='black')
plt.yticks(df.index+0.2,df['Species name'].values) #设置
plt.tick_params(labelsize
python横向柱状图
最新推荐文章于 2022-09-07 21:37:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)