熟悉python可视化的设计
完成综合小程序的设计。
登录系统设计
from tkinter import *
import tkinter.messageboxdef onClick():
name=bname.get()
pwd=bpwd.getO()
if (name=='zhou' and pwd=='123'):
tkinter.messagebox.showinfo(title='提示',message='登陆成功!')
else:
tkinter.messagebox.showerror(title='提示',message='输入错误!')m=Tk()
m.title('欢迎登录系统')
m.geometry('300x150')
Label(m,text='用户名').grid(row=0,column=0)
Label(m,text='密码').grid(row=1,column=0)
bname=Entry(m)
bname.grid(row=0,column=1)
bpwd=Entry(m,show='*')
bpwd.grid(row=1,column=1)
Button(m,text='登陆',command=onClick).grid(row=2,column=0)Button(m,text='退出',command=quit).grid(row=2,column=1)
mainloop()
学生课程成绩等级分布
import matplotlib.pyplot as plt
import numpy as npgrade=['<60','60-69','70-79','80-89','90-100']
nScore1=[3,15,24,12,8]
nScore2=[2,25,14,16,3]plt.figure(figsize=(10,6))
plt.subplot(2,2,1)
plt.bar(grade,nScore1)
plt.bar(grade,nScore2)plt.subplot(2,2,2)
plt.scatter(grade,nScore1)
plt.scatter(grade,nScore2)plt.subplot(2,2,3)
plt.plot(grade,nScore1)
plt.plot(grade,nScore2)plt.subplot(2,2,4)
plt.pie(nScore1,labels=grade,radius=1.2,autopct='%1.1f%%',explode=[0,0,0.1,0,0])
plt.suptitle('学生课程成绩等级分布',fontname='SimHei',fontsize=18)
plt.show()
图片引入
标签:plt,grade,程序,grid,import,np,设计,综合,row From: https://blog.csdn.net/cxh666888_/article/details/143041828# -*- coding: utf-8 -*-
"""
Created on Fri Oct 18 11:00:04 2024@author: Administrator
"""import numpy as np
import matplotlib.pyplot as pltfig=plt.figure(figsize=(6,6))
ax1=fig.add_subplot(211)
ax2=fig.add_subplot(212)girl=plt.imread("1.jpg")
ax1.imshow(girl)n=60
x=np.random.rand(n)*80
y=np.random.rand(n)*100
n1=np.random.rand(n)
n2=np.random.rand(n)
area=np.pi*(15*n1)**2
color=2*np.pi*n2
ax2.scatter(x,y,s=area,c=color,alpha=0.5,cmap=plt.cm.hsv)plt.show()