From 072ed88845a4d936f9ff695d4c2c169fab31e4ab Mon Sep 17 00:00:00 2001 From: HuangYixin <237842420@qq.com> Date: Mon, 27 May 2024 12:31:16 +0800 Subject: [PATCH] 001 --- AirQuilitySys/.idea/.gitignore | 3 + AirQuilitySys/.idea/AirQuilitySys.iml | 10 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ AirQuilitySys/.idea/misc.xml | 7 ++ AirQuilitySys/.idea/modules.xml | 8 ++ AirQuilitySys/AirQui.py | 76 +++++++++++++++++++ AirQuilitySys/Login.py | 39 ++++++++++ AirQuilitySys/data.py | 7 ++ AirQuilitySys/replace.py | 7 ++ AirQuilitySys/time.py | 0 10 files changed, 163 insertions(+) create mode 100644 AirQuilitySys/.idea/.gitignore create mode 100644 AirQuilitySys/.idea/AirQuilitySys.iml create mode 100644 AirQuilitySys/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 AirQuilitySys/.idea/misc.xml create mode 100644 AirQuilitySys/.idea/modules.xml create mode 100644 AirQuilitySys/AirQui.py create mode 100644 AirQuilitySys/Login.py create mode 100644 AirQuilitySys/data.py create mode 100644 AirQuilitySys/replace.py create mode 100644 AirQuilitySys/time.py diff --git a/AirQuilitySys/.idea/.gitignore b/AirQuilitySys/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/AirQuilitySys/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/AirQuilitySys/.idea/AirQuilitySys.iml b/AirQuilitySys/.idea/AirQuilitySys.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/AirQuilitySys/.idea/AirQuilitySys.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/AirQuilitySys/.idea/inspectionProfiles/profiles_settings.xml b/AirQuilitySys/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/AirQuilitySys/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/AirQuilitySys/.idea/misc.xml b/AirQuilitySys/.idea/misc.xml new file mode 100644 index 0000000..5cc6554 --- /dev/null +++ b/AirQuilitySys/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/AirQuilitySys/.idea/modules.xml b/AirQuilitySys/.idea/modules.xml new file mode 100644 index 0000000..d8e5789 --- /dev/null +++ b/AirQuilitySys/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/AirQuilitySys/AirQui.py b/AirQuilitySys/AirQui.py new file mode 100644 index 0000000..339e28b --- /dev/null +++ b/AirQuilitySys/AirQui.py @@ -0,0 +1,76 @@ +import matplotlib.pyplot as plt +# 创建图形和坐标轴对象,指定尺寸和DPI +fig, ax = plt.subplots(figsize=(13.33,7.5), dpi = 96) +# 绘制折线 +for country in top_20_countries: + data = df[df['Country Name'] == country] + line = ax.plot(data['Year'], data['GDP'], label=country) +# 添加图例 +ax.legend(loc="best", fontsize=8) +# 创建网格 +ax.grid(which="major", axis='x', color='#DAD8D7', alpha=0.5, zorder=1) +ax.grid(which="major", axis='y', color='#DAD8D7', alpha=0.5, zorder=1) +# 重新格式化x轴标签和刻度线标签 +ax.set_xlabel('', fontsize=12, labelpad=10) +# 不需要轴标签 +ax.xaxis.set_label_position("bottom") +ax.xaxis.set_major_formatter(lambda s, i : f'{s:,.0f}') +#以防万一我们需要额外的格式设置 +ax.xaxis.set_major_locator(MaxNLocator(integer=True)) +#以防我们需要额外的格式化 +ax.xaxis.set_tick_params(pad=2, labelbottom=True, bottom=True, labelsize=12, labelrotation=0) +# 重新格式化y轴 +ax.set_ylabel('GDP (Billions USD)', fontsize=12, labelpad=10) +ax.yaxis.set_label_position("left") +ax.yaxis.set_major_formatter(lambda s, i : f'{s*10**-9:,.0f}') +ax.yaxis.set_major_locator(MaxNLocator(integer=True)) +#以防我们需要额外的格式化 +ax.yaxis.set_tick_params(pad=2, labeltop=False, labelbottom=True, bottom=False, labelsize=12) + +# 颜色和线条样式 +colors_dict = {'United States': '#014f86', 'China': '#DC0000', 'Japan': '#ff4d6d', 'Germany': '#403d39', 'India': '#6a994e'} + +line_styles_dict = {'United States': '-', 'China': '-', 'Japan': '-', 'Germany': '-', 'India': '-'} +# 绘制前5条线 +for country in top_20_countries[:5]: + color = colors_dict.get(country, 'grey') + # 从字典中获取颜色,如果找不到,默认为灰色 + line_style = line_styles_dict.get(country, '-') + # 从字典中获取线条样式,如果未找到,默认为实线 + data = df[df['Country Name'] == country] + line = ax.plot(data['Year'], data['GDP'], color=color, linestyle=line_style, zorder=2, label=country) + # 添加图例 + ax.legend(loc="best", fontsize=8) + # 绘制剩余部分 + for country in top_20_countries[5:]: + data = df[df['Country Name'] == country] + line = ax.plot(data['Year'], data['GDP'], color='grey', linestyle=':', linewidth=0.5, zorder=2) +# 移除边框 +ax.spines[['top','right','bottom']].set_visible(False) +# 加粗左侧边框 +ax.spines['left'].set_linewidth(1.1) +# 在顶部添加红线和矩形 +ax.plot([0.05, .9], [.98, .98], transform=fig.transFigure, clip_on=False, color='#E3120B', linewidth=.6) +ax.add_patch(plt.Rectangle((0.05,.98), 0.04, -0.02, facecolor='#E3120B', transform=fig.transFigure, clip_on=False, linewidth = 0)) +# 添加标题和副标题 +ax.text(x=0.05, y=.93, s="Evolution of the 20 Richest Countries GDP over the Past 50 Years", transform=fig.transFigure, ha='left', fontsize=14, weight='bold', alpha=.8) +ax.text(x=0.05, y=.90, s="Focus on the current 5 richest countries from 1973 to 2022", transform=fig.transFigure, ha='left', fontsize=12, alpha=.8) +# 设置来源文本 +ax.text(x=0.05, y=0.12, s="Source: World Bank - https://databank.worldbank.org/", transform=fig.transFigure, ha='left', fontsize=10, alpha=.7) +# 调整绘图区域周围的边距 +plt.subplots_adjust(left=None, bottom=0.2, right=None, top=0.85, wspace=None, hspace=None) +# 设置白色背景 +fig.patch.set_facecolor('white') +# 绘制前5条线 +for country in top_20_countries[:5]: + color = colors_dict.get(country, 'grey') + # 从字典中获取颜色,如果找不到,默认为黑色 + line_style = line_styles_dict.get(country, '-') + # 从字典中获取线条样式,如果找不到,默认为实线 + data = df[df['Country Name'] == country] + line = ax.plot(data['Year'], data['GDP'], color=color, linestyle=line_style, zorder=2, label = country) + ax.plot(data['Year'].iloc[-1], data['GDP'].iloc[-1], 'o', color=color, markersize=10, alpha=0.3) + ax.plot(data['Year'].iloc[-1], data['GDP'].iloc[-1], 'o', color=color, markersize=5) + # 在图表上添加一些文字 + ax.annotate('During the 2000s,\nChina began experiencing rapid economic growth,\noutpacing all other countries.', (data['Year'].iloc[-18], 2000000000000), xytext=(data['Year'].iloc[-28]-timedelta(days=500), 18000000000000), ha='left', fontsize=9, arrowprops=dict(arrowstyle='-|>', facecolor='k', connectionstyle="arc3,rad=-0.15")) + diff --git a/AirQuilitySys/Login.py b/AirQuilitySys/Login.py new file mode 100644 index 0000000..8aef3dd --- /dev/null +++ b/AirQuilitySys/Login.py @@ -0,0 +1,39 @@ +from tkinter import * +user_login={'aaa':'123456','bbb':'888888','ccc':'333333'} +count=0 +def login(): + global count + username=entry_username.get() + if username not in user_login: + label_message.config(text='账号错误!') + else: + password=entry_password.get() + if(password==user_login[username]): + label_message.config(text='登录成功!') + else: + label_message.config(text='密码错误!还可以尝试{}次'.format(2-count)) + count=count+1 + if count == 3: + label_message.config(text='登录失败!') + btn_login.config(state="disabled") + +window=Tk() +window.title("用户登录") +window.geometry("300x200") + +label_username=Label(window,text="账号:") +label_username.pack() + +entry_username=Entry(window) +entry_username.pack() + +label_password=Label(window,text="密码:") +label_password.pack() + +entry_password=Entry(window,show='*') +entry_password.pack() + +label_message=Label(window,text="") +label_message.pack() + +window.mainloop() \ No newline at end of file diff --git a/AirQuilitySys/data.py b/AirQuilitySys/data.py new file mode 100644 index 0000000..4624836 --- /dev/null +++ b/AirQuilitySys/data.py @@ -0,0 +1,7 @@ +import requests +res = requests.get('http://www.daqi110.com/content/environment/index.html') +print(res) +print(type(res)) +>>> + + \ No newline at end of file diff --git a/AirQuilitySys/replace.py b/AirQuilitySys/replace.py new file mode 100644 index 0000000..8c72462 --- /dev/null +++ b/AirQuilitySys/replace.py @@ -0,0 +1,7 @@ +import re +path = '时间数据'+'txt' +with open(path,'r+',encoding='utf-8')as f1: + text1 =f1.read() + pattern=r'{"ci":' + replacement='' + text2=re.sub(pattern,'',text1) diff --git a/AirQuilitySys/time.py b/AirQuilitySys/time.py new file mode 100644 index 0000000..e69de29