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 @   carol2014  阅读(25)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示