1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import pandas as pd import matplotlib.pyplot as plt plt.rcParams[ 'font.sans-serif' ] = [ 'SimHei' ] plt.rcParams[ 'axes.unicode_minus' ] = False plt.figure() url = r "D:\ju\catering_fish_congee(1).xls" data = pd.read_excel(url) p = data.boxplot(return_type = ( 'dict' )) x = p[ 'fliers' ][ 0 ].get_xdata() y = p[ 'fliers' ][ 0 ].get_ydata() y.sort() # print(data.describe().max()) # print(data) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import pandas as pd import matplotlib.pyplot as plt #导入绘图包 plt.rcParams[ 'font.sans-serif' ] = [ 'SimHei' ] #解决中文显示问题 plt.rcParams[ 'axes.unicode_minus' ] = False # 解决中文显示问题 url = r "D:\资料\python\数据\catering_dish_profit.xls" data = pd.read_excel(url) #饼图 plt.figure(figsize = ( 6 , 6 )) #将画布设定为正方形,则绘制的饼图是正圆 plt.pie(data[ '盈利' ], labels = data[ '菜品名' ]) plt.title( '菜品销售量分布饼图--number:3003' ) #加标题 plt.show() #条形图 plt.figure(figsize = ( 8 , 4 )) plt.bar(data[ '菜品名' ],data[ '盈利' ]) plt.xlabel( '菜品' ) plt.ylabel( '销量' ) plt.title( '菜品销售量条形图--number:3003' ) #加标题 plt.show() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import pandas as pd import matplotlib.pyplot as plt #导入绘图包 plt.rcParams[ 'font.sans-serif' ] = [ 'SimHei' ] #解决中文显示问题 plt.rcParams[ 'axes.unicode_minus' ] = False # 解决中文显示问题 url = r "D:\资料\python\数据\dish_sale.xls" data = pd.read_excel(url) #画折线图对比数据 plt.figure(figsize = ( 12 , 8 )) plt.plot(data[ '月份' ],data[ 'A部门' ],color = 'green' ,label = 'A部门' ,marker = 'o' ) plt.plot(data[ '月份' ],data[ 'B部门' ],color = 'red' ,label = 'B部门' ,marker = 's' ) plt.plot(data[ '月份' ],data[ 'C部门' ],color = 'skyblue' ,label = 'C部门' ,marker = 'x' ) plt.xlabel( '月份' ) plt.ylabel( '销售额(万元)' ) plt.title( '菜品销售量折线对比图--number:3003' ) #加标题 plt.legend() #显示图例 plt.show() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import numpy as np import matplotlib.pyplot as plt #导入绘图包 import math plt.rcParams[ 'font.sans-serif' ] = [ 'SimHei' ] #解决中文显示问题 plt.rcParams[ 'axes.unicode_minus' ] = False # 解决中文显示问题 x = np.arange( 0 , 2 * math.pi, 0.1 ) #以0.1为单位,生成0到6的数据 y = np.sin(x) plt.figure(figsize = ( 12 , 8 )) plt.plot(x,y,color = 'skyblue' ,label = 'f(x)=sin x' ,marker = 'o' ) plt.title( 'f(x)=sin x在(0,2Π)的函数图象--number:3003' ) #加标题 plt.xlabel( 'X' ) plt.ylabel( 'Y' ) plt.legend() #显示图例 plt.show() |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人