python3的hello world

最近需要用echarts画带数据点的箱型图,然而echarts5.1的版本只有带离散点的箱型图,像这种

 

我需要这种,本人水平有限,想不到怎么用echarts实现下面的图形的绘制

 

经过查资料,发现可以用python3的seaborn实现

import seaborn as sns
import matplotlib.pyplot as plt

fig=plt.figure(figsize=(20,5))

# fig.patch.set_facecolor('grey')

sns.set(style="darkgrid")
# 加载示例数据集,把数据集下载到本地,指定加载路径
df = sns.load_dataset('iris',data_home="E:\code\learn-python3\seaborn-data-master")
df.head()

print(df)

# 添加扰动点
# boxplot
ax = sns.boxplot(x='species', y='sepal_length', data=df)
# add stripplot
ax = sns.stripplot(x='species', y='sepal_length', data=df, color="orange", jitter=0.2, size=4)

# add title
plt.title("Boxplot with jitter", loc="top")

# show the graph
# plt.show()
plt.savefig('1.jpg')  

 

顺便把用到的python3知识记录下 

#查询mysql数据库
import pymysql
db = pymysql.connect(host="127.0.0.1",user="root", password="",port=3306, database="test",charset='utf8')
cursor = db.cursor()

sql="select *  from tb_chinese_poems limit 5" # sql语句
try:
    cursor.execute(sql)
    results =cursor.fetchall() # 获取数据
    for row in results :
      print(row)
except:
    print("Error: unable to fecth data")
#发送请求
import requests
url="http://localhost/test.php"
response=requests.get(url,params={"p1":1})
print(response.text) 
#接收命令行参数
import sys
print(sys.argv)

 

posted @ 2022-10-26 17:06  carol2014  阅读(20)  评论(0编辑  收藏  举报