python-批量画子图+添加主标题+解决中文乱码

totobey 2022-06-23 17:48:08 阅读数:782

Python批量添加标题python-

import numpy as np
import pandas as pd
import time #统计运行时间用
import copy #深拷贝的时候用
import _pickle as cPickle
import gc #释放内存使用
from tqdm import tqdm,tqdm_notebook #Tqdm 是一个快速,可扩展的Python进度条
import datetime #处理时间数据
import os
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator, FormatStrFormatter
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
import seaborn as sns
%matplotlib inline
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.filterwarnings("ignore")
pd.set_option('display.max_columns',100)
pd.set_option('max_colwidth',100)
baseline_cols=['verbal_memory_baseline','visual_memory_baseline','visual-motor_speed_baseline'
,'reaction_time_baseline','impulse_control_baseline','total_symptom_baseline']
#画直方图
fig = plt.figure(figsize=(15, 6))
sns.set_style("darkgrid", {'font.sans-serif': ['simhei','FangSong']}) #s设立风格
# sns.set_style('whitegrid', {'font.sans-serif': ['simhei','FangSong']})
plt.suptitle('control group的baseline指标直方图',fontsize=20) #设置主标题
for i,col in enumerate(baseline_cols):
plt.subplot(2, 3, i + 1)
plt.hist(control[col])
plt.xlabel(col,fontsize=12)
plt.tight_layout()

 

版权声明:本文为[totobey]所创,转载请带上原文链接,感谢。 https://blog.csdn.net/totobey/article/details/125382066