
---------------------------------------------------------------------------------------------------------------------------------------------------------
1 2 3 4 5 6 7 8 9 10 11 | #设置轴标题 #画布设置颜色和大小 #折线图设置标记样式,,mfc='w'表示空心 import matplotlib.pyplot as plt x = [ 1 , 2 , 3 , 4 , 5 ] y = [ 2 , 10 , 6 , 7 , 17 ] plt.rcParams[ 'font.sans-serif' ] = [ 'SimHei' ] plt.figure(facecolor = 'yellow' ,figsize = ( 5 , 3 )) plt.xlabel( '2021年五一' ) #x轴的标题 plt.ylabel( '室外温度' ) #y轴的标题 plt.plot(x,y,marker = 'o' ,color = 'r' ,mfc = 'w' ) #r表示颜色,1表示标记样式(下花三角标记) plt.show() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #设置坐标轴的刻度 ,坐标范围,网格线 import matplotlib.pyplot as plt import random x = [i for i in range ( 1 , 11 )] # 列表生成式 y = [random.randint ( 1 , 10 ) for _ in range ( 10 )] plt.plot(x, y, marker = 'o' ,mfc = 'w' ) month = [ str (i) + '月' for i in range ( 1 , 11 )] plt.xticks( range ( 1 , 11 ),month) #设置x轴坐标轴刻度 plt.yticks( range ( 1 , 11 )) #设置x轴坐标轴刻度 plt.xlim( 1 , 10 ) #设置x坐标轴范围 plt.ylim( 1 , 20 ) #设置y坐标轴范围 #设置网格 #灰度0.5 ,线为双划线,线的宽度为1,去掉x轴网格线 plt.grid(color = '0.5' , linestyle = '--' ,linewidth = '1' ,axis = "x" ) #设置网格 #灰度0.5 plt.show() |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)