1 小提琴图示意
2 使用seaborn绘制的效果
3 绘图并将四分位和95%置信区间数据写入CSV,注意修改linkdatabase函数中mysql中的账号密码
import math
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from sqlalchemy import create_engine
import seaborn as sns
import pandas as pd
matplotlib.rc("font",family='YouYuan')
def trans(m):
return list(zip(*m))
def linkdatabase():
engine = create_engine("mysql+pymysql://{}:{}@{}:{}/{}".format('账号', '密码', 'localhost', '3306', 'zhangduoduo_www'))
sql_query = 'select * from xiangdui where miruqi = 3 ;'
X2 = pd.read_sql_query(sql_query, engine)
sql_query1 = 'select mother_id as mother_id1 ,sumaa,baa as baa1 from yuanshi where miruqi = 3 ;'
X1 = pd.read_sql_query(sql_query1, engine)
sumX = pd.concat([X2, X1], axis=1)
print('linkdatabase')
return sumX
def plot(iris_t2,filename):
X = iris_t2
g = sns.PairGrid(X,
x_vars=['city', 'age1', 'birth_jd','fenmian_way