首页 文章 精选 留言 我的

精选列表

搜索[统计],共10003篇文章
优秀的个人博客,低调大师

ModStartCMS v6.1.0 网站简单统计,后台操作优化

系统介绍 ModStart 是一个基于 Laravel 模块化极速开发框架。模块市场拥有丰富的功能应用,支持后台一键快速安装,让开发者能快的实现业务功能开发。 系统完全开源,基于 Apache 2.0 开源协议,免费且不限制商业使用。 功能特性 丰富的模块市场,后台一键快速安装 会员模块通用且完整,支持完整的API调用 大文件分片上传,进度条显示,已上传文件管理 强大的模块扩展功能,所有模块可以无缝集成,支持在线安装、卸载模块 完善的开发助手,实现模块、主题的的一键创建 完善的后台权限管理,支持基于RBAC的权限管理系统 后台管理支持使用手机、平板、PC,无论何时何地都可方便管理 第三方登录(QQ、微信、微博、支付宝、微信小程序) 第三方支付支持(微信、支付宝、支付宝当面付、微信扫码、微信小程序) 第三方云存储支持,支持云储存分片上传(阿里云、百度云、华为云、腾讯云、FTP、七牛云、UCloud、又拍云) 第三方短信支持(阿里云、腾讯云、华为云、百度云、253云通讯、聚合、七牛云、融云、赛邮、UCloud、云片、网易云) V6.1.0版本更新 2023年04月04日ModStartCMS发布v6.1.0版本,增加了以下25个特性: [新功能] 基本设置支持其他备案信息 [新功能] 后台待审核链接在新标签页打开 [新功能] GridFilter增加数字和文本范围查询 [新功能] 文件即将上传和文件上传完成事件 [新功能] Select组件和Grid筛选新增selectSearch属性,选项可搜索 [新功能] Number、Decimal、Currency组件添加符号显示(signShow)和自动着色(autoColor)配置 [新功能] LayUI升级到最新版,移除独立Layer [新功能] 轮播图增加背景颜色和container模式,适配大屏模式的显示 [新功能] 为jQuery新增serializeJson方法 [新功能] 请求错误新增具体错误码和错误信息 [新功能] 用户后台积分流水、现金流水增加用户ID筛选 [新功能] 数据库字符集默认调整为utf8mb4 [新功能] 网站信息新增联系信息,支持邮箱电话等联系方式 [新功能] 折线图表数据库使用优化 [新功能] ModStartRequestHandled事件 [新功能] 新闻、案例、产品新增上一篇下一篇导航 [新功能] 网站默认宽度调整为60rem [新功能] AdminUser表单组件 [新功能] 系统样式随机颜色升级 [新功能] 后台用户钱包充值订单 [新功能] 短信发送使用任务队列替代同步发送 [系统优化] 后台用户管理操作方式优化 [系统优化] 用户消息模板查找路径 [系统优化] 安装配置文件缺少数据库端口配置问题修复 [系统优化] Decimal数据输入内容过滤和处理 模块市场一键安装 系统内置模块市场,有行业应用、插件、云存储、云短信等功能模块,后台支持一键安装、启用、禁用、卸载,可快速搭建属于自己的系统应用。 系统演示与文档 码云仓库:https://gitee.com/modstart/ModStartCMS Github仓库:https://github.com/modstart/ModStartCMS 系统演示:https://cms.demo.tecmz.com/ 下载试用:https://modstart.com/download 开发者文档:https://modstart.com/doc 模块市场:https://modstart.com/store

优秀的个人博客,低调大师

ModStartBlog v7.0.0 网站简单统计,支持博客分享

系统介绍 ModStart 是一个基于 Laravel 模块化极速开发框架。模块市场拥有丰富的功能应用,支持后台一键快速安装,让开发者能快的实现业务功能开发。 系统完全开源,基于 Apache 2.0 开源协议。 功能特性 丰富的模块市场,后台一键快速安装 会员模块通用且完整,支持完整的API调用 大文件分片上传,进度条显示,已上传文件管理 强大的模块扩展功能,所有模块可以无缝集成,支持在线安装、卸载模块 完善的开发助手,实现模块、主题的的一键创建 完善的后台权限管理,支持基于RBAC的权限管理系统 后台管理支持使用手机、平板、PC,无论何时何地都可方便管理 第三方登录(QQ、微信、微博、支付宝、微信小程序) 第三方支付支持(微信、支付宝、支付宝当面付、微信扫码、微信小程序) 第三方云存储支持,支持云储存分片上传(阿里云、百度云、华为云、腾讯云、FTP、七牛云、UCloud、又拍云) 第三方短信支持(阿里云、腾讯云、华为云、百度云、253云通讯、聚合、七牛云、融云、赛邮、UCloud、云片、网易云) V7.0.0版本更新 2023年03月28日ModStartBlog发布v7.0.0版本,增加了以下28个特性: [新功能] 组件验证规则支持数组添加,自动过滤空值 [新功能] 折线图表数据库使用优化 [新功能] ModStartRequestHandled事件 [新功能] 网站默认宽度调整为60rem [新功能] AdminUser表单组件 [新功能] 系统样式随机颜色升级 [新功能] 短信发送使用任务队列替代同步发送 [新功能] 数据库字符集默认调整为utf8mb4 [新功能] 后台待审核链接在新标签页打开 [新功能] GridFilter增加数字和文本范围查询 [新功能] 文件即将上传和文件上传完成事件 [新功能] Select组件和Grid筛选新增selectSearch属性,选项可搜索 [新功能] 网站信息新增联系信息,支持邮箱电话等联系方式 [新功能] 基本设置支持其他备案信息 [新功能] Values组件新增viewMode,支持mini一行显示模式 [新功能] 网页首页标题新增加副标题 [新功能] data-header-sticky-disable特性可部分页面禁止头部滚动 [新功能] UEditorPlus升级3.0.0 [新功能] 安装向导增加zip和curl的PHP扩展检测 [新功能] 集成ShareJS,支持博客一键分享 [新功能] 数据库调整为严格模式(字段截取抛出异常) [系统优化] Decimal数据输入内容过滤和处理 [系统优化] 搜索引擎爬虫引导,增加部分链接ref=nofollow属性 [系统优化] 富文本编辑器UEditor样式缓存问题 [系统优化] 表单处理JS部分代码逻辑重构 [Bug修复] 博客列表移动端标题显示异常问题 [Bug修复] 后台管理角色增加异常问题 [Bug修复] 博客留言回复显示异常问题 模块市场一键安装 系统内置模块市场,有行业应用、插件、云存储、云短信等功能模块,后台支持一键安装、启用、禁用、卸载,可快速搭建属于自己的系统应用。 系统演示与文档 码云仓库:https://gitee.com/modstart/ModStartBlog Github仓库:https://github.com/modstart/ModStartBlog 系统演示:https://blog.demo.tecmz.com/ 下载试用:https://modstart.com/download 开发者文档:https://modstart.com/doc 模块市场:https://modstart.com/store

优秀的个人博客,低调大师

Python制图 | 01.使用Matplotlib绘制统计

Section One - Plotting with Matplotlib 源代码 学习目标: 解释matplotlib面向对象的绘图方法 使用matplotlib创建不同类型的绘图 使用matplotlib自定义绘图(包括标签和颜色) 使用matplotlib创建具有多个子图的绘图 Matplotlib是Python中最常用的绘图库,下面了解如何开始使用matplotlib创建和自定义绘图 1.1 概述 Matplotlib是一个Python绘图包,它使从存储在各种数据结构中的数据(包括列表、numpy数组和pandas数据框)创建二维图变得简单。Matplotlib使用了一种面向对象的绘图方法。这意味着可以通过向绘图中添加新的元素来逐步构建绘图 matplotlib绘图中主要会用到两个对象: figure对象:整体的图空间,可以包含一个或多个子图 axis对象:在图空间中呈现的各个子图,可以把figure对象看作是整个绘图画布,而axis对象看作是其中的一个子图 一个图空间可以容纳一个或多个axis对象,这种结构允许我们创建带有一个或多个子图的图形 虽然Matplotlib包含许多模块,提供不同的绘图功能,但最常用的模块是pyplot Pyplot提供的方法可用于向图形对象添加不同的组件,包括将各个图创建为axis对象,也就是子图 pyplot模块通常使用别名plt导入,如下所示: # Import pyplot import matplotlib.pyplot as plt 1.2 使用Matplotlib创建图像 要使用matplotlib的面向对象方法创建一个图,首先要使用pyplot模块中的subplots()函数创建一个图(可以称为fig)和至少一个轴(可以称为ax) fig, ax = plt.subplots() 请注意,通过将fig和ax设置为等于pyplot.subplots()函数的输出值,fig和ax被同时创建。由于没有提供其他参数,结果是一个带有一个空图的图 # Create figure and one plot (axis object) fig, ax = plt.subplots() 1.3 更改图片大小 使用figsize参数设置绘图空间的宽和高 figsize = (width, height) # Resize figure fig, ax = plt.subplots(figsize = (10, 6)) 1.4 绘制多个子图 使用matplotlib的面向对象方法,通过创建额外的axis对象,可以更容易地在图空间中创建多个子图 当添加多个axis对象时,最好的做法是给它们不同的名称(如ax1和ax2),这样就可以很容易地单独使用每个axis 因此,需要为plt.subplots提供新的参数,用于图的布局:(行数,列数) plt.subplots(1, 2) 在本例中,1、2表示布局为1行,2列 # Figure with two plots fig, (ax1, ax2) = plt.subplots(1, 2, figsize = (10, 6)) 相反地,(2,1)表示2行,1列格局分布 fig, (ax1, ax2) = plt.subplots(2, 1, figsize = (10, 6)) 由于定义了figsize=(10,6),figure绘图空间会保持这个大小,无论如何设置行数或列数是多少 但是,可以调整行数、列数以及figsize,以得到需要的大小 # Figure with two plots fig, (ax1, ax2) = plt.subplots(2, 1, figsize = (12, 12)) 可以根据需要继续添加任意数量的axis对象,以创建所需图形的整体布局,并根据需要继续调整图形大小 # Figure with three plots fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize = (15, 15)) Matplotlib 面向对象方法的一个主要优点是,每个axis都是独立的的对象,可以独立于图中的其他绘图独立地进行自定义绘制 2 使用 Matplotlib 绘制自定义图表 在本章的前面,学习了如何使用pyplot中的subplot ()函数创建图形和轴对象(使用别名plt导入) : fig,ax = plt.subplots() 现在已经知道如何使用matplotlib创建基本的绘图,可以开始向图中的绘图添加数据了 首先导入别名plt的matplotlib.pyplot模块,并创建一些列表来绘制由美国国家海洋和大气管理局(NOAA)提供的*科罗拉多州博尔德市的月平均降水量(英寸)* # Import pyplot 导入包 import matplotlib.pyplot as plt # Monthly average precipitation 月平均降水量 boulder_monthly_precip = [0.70, 0.75, 1.85, 2.93, 3.05, 2.02, 1.93, 1.62, 1.84, 1.31, 1.39, 0.84] # Month names for plotting 月份 months = ["Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"] 2.1 使用 Matplotlib 绘制数据 可以通过调用所需的ax对象将数据添加到绘图中,该对象是先前定义的axis元素: fig,ax = plt.subplots() 通过调用ax对象的plot()方法,并指定绘图的x轴(水平轴)和y轴(垂直轴)的参数如下 plot(x_axis, y_axis) 在这个例子中,你正在从之前定义的列表中添加数据,数据沿着x轴和y轴分布 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months, boulder_monthly_precip) [<matplotlib.lines.Line2D at 0x7f0b21ed3e48>] 可以注意到,输出显示了图形的对象类型以及唯一标识符(内存位置) [<matplotlib.lines.Line2D at 0x7f81afe900b8>] 可以通过在代码末尾调用plt.show()来隐藏该信息 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months,boulder_monthly_precip) plt.show() 2.2 Matplotlib Plot 对象的命名约定 Python 社区中的惯例是使用ax来命名axis对象,但这并不是唯一的 # Define plot space with ax named bob fig, bob = plt.subplots(figsize=(10, 6)) # Define x and y axes bob.plot(months,boulder_monthly_precip) plt.show() 2.3 创建不同类型的Matplotlib图: 散点图和条形图 默认情况下,ax.plot 将绘图创建为线图(这意味着所有的值都通过横跨绘图的连续线连接起来) 可以使用 ax 对象来创建: 散点图(使用ax.scatter) : 值显示为不连续线的单个点 条形图(使用ax.bar) : 值显示为条形,其高度指示特定点的值 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Create scatter plot ax.scatter(months,boulder_monthly_precip) plt.show() # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Create bar plot ax.bar(months,boulder_monthly_precip) plt.show() 2.4 自定义绘图标题和坐标轴标签 可以使用ax.set()方法中的title、xlabel、ylabel参数为轴添加绘图标题和标签,从而自定义和添加更多信息到绘图中 ax.set(title = "Plot title here", xlabel = "X axis label here", ylabel = "Y axis label here") # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months, boulder_monthly_precip) # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation in Boulder, CO", xlabel = "Month", ylabel = "Precipitation (inches)") plt.show() 2.5 自定义多行绘图标题和坐标轴标签 使用两个单词之间的新行字符**\n**创建具有多行文本的标题和轴标签 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months, boulder_monthly_precip) # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.6 标签旋转 使用plt.setp函数设置整个绘图空间的参数,如自定义刻度标签 在下面的例子中,ax.get_xticklabels()函数控制x轴的刻度标签,rotation # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months, boulder_monthly_precip) # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.setp(ax.get_xticklabels(),rotation=45) plt.show() 2.7 自定义折线、点标记形状 可以通过marker=参数对线段、点的形状标识进行修改 Marker symbol Marker description . point , pixel o circle v triangle_down ^ triangle_up < triangle_left > triangle_right 访问Matplotlib文档可以获取更多标记类型列表 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.scatter(months, boulder_monthly_precip, marker = ',') # pixel # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months, boulder_monthly_precip, marker = 'o') # point # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.8 自定义绘图颜色 可以使用color参数自定义绘图颜色,在matplotlib中提供的一些基本颜色选项列表如下: b: blue g: green r: red c: cyan m: magenta y: yellow k: black w: white 对于这些基本颜色,可以将color参数设置为等于全名(例如cyan)或者仅仅是如上表所示的键字母(例如c) 要获得更多的颜色,请访问关于颜色的matplotlib文档 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.plot(months, boulder_monthly_precip, marker = 'o', color = 'cyan') # color=c # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.scatter(months, boulder_monthly_precip, marker = ',', color = 'k') # color=black # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.bar(months, boulder_monthly_precip, color = 'darkblue') # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.8 设置颜色透明度 使用alpha =参数调整颜色的透明度,其值接近0.0表示更高的透明度 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.bar(months, boulder_monthly_precip, color = 'darkblue', alpha = 0.3) # 透明度设置 # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.9 自定义条形图的颜色 通过使用参数edgeccolor=将每个条的轮廓颜色更改为蓝色,并从前面讨论过的matplotlib颜色选项中指定一种颜色,可以进一步自定义条形图 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.bar(months, boulder_monthly_precip, color = 'cyan', edgecolor = 'darkblue') # 轮廓颜色设置 # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.10 自定义散点图的颜色 在使用散点图时,还可以使用c和cmap参数根据每个点的数据值为其分配一种颜色 c参数允许指定将被颜色映射的值序列(例如boulder _ monthly _ precip) ,而cmap允许指定用于该序列的颜色映射 下面的例子使用了YlGnBu颜色图,其中较低的值用黄色到绿色色调填充,而较高的值用越来越深的蓝色色调填充 要查看彩色地图选项列表,请访问的matplotlib cmpas文档 # Define plot space fig, ax = plt.subplots(figsize=(10, 6)) # Define x and y axes ax.scatter(months, boulder_monthly_precip, c = boulder_monthly_precip, cmap = 'YlGnBu') # Set plot title and axes labels ax.set(title = "Average Monthly Precipitation\nBoulder, CO", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.11 将数据绘制为多图 回想matplotlib的面向对象方法,通过创建额外的axis对象,可以很容易地在一个图形中包含多个图形: fig, (ax1, ax2) = plt.subplots(num_rows, num_columns) 一旦定义了fig和两个axis对象,就可以向每个轴添加数据并定义具有独特特征的图形 在下面的示例中,ax1.bar在第一个绘图中创建一个定制的条形图,而ax2.scatter在第二个绘图中创建一个定制的散点图 # Define plot space fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 12)) # 两行一列 # Define x and y axes ax1.bar(months, boulder_monthly_precip, color = 'cyan', edgecolor = 'darkblue') # Define x and y axes ax2.scatter(months, boulder_monthly_precip, c = boulder_monthly_precip, cmap = 'YlGnBu') plt.show() 2.12 为多个子图添加标题和轴标签 可以继续添加ax1和ax2,例如为每个单独的绘图添加标题和轴标签,就像您以前只有一个绘图时所做的那样 可以使用ax1.set()为第一个绘图(柱状图)定义元素,使用ax2.set()为第二个绘图(散点图)定义元素 # Define plot space fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 12)) # Define x and y axes ax1.bar(months, boulder_monthly_precip, color = 'cyan', edgecolor = 'darkblue') # Set plot title and axes labels ax1.set(title = "Bar Plot of Average Monthly Precipitation", xlabel = "Month", ylabel = "Precipitation\n(inches)"); # Define x and y axes ax2.scatter(months, boulder_monthly_precip, c = boulder_monthly_precip, cmap = 'YlGnBu') # Set plot title and axes labels ax2.set(title = "Scatter Plot of Average Monthly Precipitation", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 现在已经有了多个图形(每个图形都有自己的标签) ,还可以为整个图形添加一个总体标题(使用指定的字体大小) ,使用: fig.suptitle("Title text", fontsize = 16) # Define plot space fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 12)) fig.suptitle("Average Monthly Precipitation for Boulder, CO", fontsize = 16) # Define x and y axes ax1.bar(months, boulder_monthly_precip, color = 'cyan', edgecolor = 'darkblue') # Set plot title and axes labels ax1.set(title = "Bar Plot", xlabel = "Month", ylabel = "Precipitation\n(inches)"); # Define x and y axes ax2.scatter(months, boulder_monthly_precip, c = boulder_monthly_precip, cmap = 'YlGnBu') # Set plot title and axes labels ax2.set(title = "Scatter Plot", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.show() 2.13 将 Matplotlib 图形保存为图像文件 可以使用以下命令轻松地将图形保存到图像文件中,例如 .png: plt.savefig ("path/name-of-file.png") 可以保存最新的数据,如果没有为文件指定一个路径,文件将会在你当前的工作目录文件夹中创建 查看Matplotlib文档以查看用于保存图形的其他文件格式的列表 # Define plot space fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 12)) fig.suptitle("Average Monthly Precipitation for Boulder, CO", fontsize = 16) # Define x and y axes ax1.bar(months, boulder_monthly_precip, color = 'cyan', edgecolor = 'darkblue') # Set plot title and axes labels ax1.set(title = "Bar Plot", xlabel = "Month", ylabel = "Precipitation\n(inches)"); # Define x and y axes ax2.scatter(months, boulder_monthly_precip, c = boulder_monthly_precip, cmap = 'YlGnBu') # Set plot title and axes labels ax2.set(title = "Scatter Plot", xlabel = "Month", ylabel = "Precipitation\n(inches)") plt.savefig("output/average-monthly-precip-boulder-co.png") plt.show() 2.14 额外资源 关于颜色条的更多信息color bars 深入介绍matplotlib 3.1 自定义x轴日期刻度 # Import required python packages import os import pandas as pd import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter import matplotlib.dates as mdates import seaborn as sns import earthpy as et # Date time conversion registration from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() # Get the data # data = et.data.get_data('colorado-flood') # Set working directory os.chdir(os.path.join(et.io.HOME, 'learning','python_data_plot')) # Prettier plotting with seaborn sns.set(font_scale=1.5) sns.set_style("whitegrid") 在本节中,将学习如何在Python中使用matplotlib绘制时间序列 # Read in the data data_path = "data/precipitation/805325-precip-dailysum-2003-2013.csv" boulder_daily_precip = pd.read_csv(data_path, parse_dates=['DATE'], # 将csv中的时间字符串转换成日期格式 na_values=['999.99'], index_col=['DATE']) boulder_daily_precip.head() <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>DAILY_PRECIP</th> <th>STATION</th> <th>STATION_NAME</th> <th>ELEVATION</th> <th>LATITUDE</th> <th>LONGITUDE</th> <th>YEAR</th> <th>JULIAN</th> </tr> <tr> <th>DATE</th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <th>2003-01-01</th> <td>0.0</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.03389</td> <td>-105.28111</td> <td>2003</td> <td>1</td> </tr> <tr> <th>2003-01-05</th> <td>NaN</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.03389</td> <td>-105.28111</td> <td>2003</td> <td>5</td> </tr> <tr> <th>2003-02-01</th> <td>0.0</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.03389</td> <td>-105.28111</td> <td>2003</td> <td>32</td> </tr> <tr> <th>2003-02-02</th> <td>NaN</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.03389</td> <td>-105.28111</td> <td>2003</td> <td>33</td> </tr> <tr> <th>2003-02-03</th> <td>0.4</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.03389</td> <td>-105.28111</td> <td>2003</td> <td>34</td> </tr> </tbody> </table> </div> # Subset the data # 提取8月15至10月15之间的数据 precip_boulder_AugOct = boulder_daily_precip["2013-08-15":"2013-10-15"] # View first few rows of data precip_boulder_AugOct.head() <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>DAILY_PRECIP</th> <th>STATION</th> <th>STATION_NAME</th> <th>ELEVATION</th> <th>LATITUDE</th> <th>LONGITUDE</th> <th>YEAR</th> <th>JULIAN</th> </tr> <tr> <th>DATE</th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <th>2013-08-21</th> <td>0.1</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.0338</td> <td>-105.2811</td> <td>2013</td> <td>233</td> </tr> <tr> <th>2013-08-26</th> <td>0.1</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.0338</td> <td>-105.2811</td> <td>2013</td> <td>238</td> </tr> <tr> <th>2013-08-27</th> <td>0.1</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.0338</td> <td>-105.2811</td> <td>2013</td> <td>239</td> </tr> <tr> <th>2013-09-01</th> <td>0.0</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.0338</td> <td>-105.2811</td> <td>2013</td> <td>244</td> </tr> <tr> <th>2013-09-09</th> <td>0.1</td> <td>COOP:050843</td> <td>BOULDER 2 CO US</td> <td>1650.5</td> <td>40.0338</td> <td>-105.2811</td> <td>2013</td> <td>252</td> </tr> </tbody> </table> </div> fig, ax = plt.subplots(figsize=(12, 8)) ax.plot(precip_boulder_AugOct.index.values, precip_boulder_AugOct['DAILY_PRECIP'].values, '-o', color='purple') ax.set(xlabel="Date", ylabel="Precipitation (Inches)", title="Daily Precipitation \nBoulder, Colorado 2013") # Format the x axis # 对x轴进行日期格式化 ax.xaxis.set_major_locator(mdates.WeekdayLocator(interval=2)) ax.xaxis.set_major_formatter(DateFormatter("%m-%d")) plt.show() 3.2 对Matplotlib进行日期格式化 在 matplotlib 中,也可以使用 DateFormatter 模块更改绘图轴上的日期格式 需要从 matplotlib 导入 DateFormatter,然后使用以下语法指定日期 DateFormatter 要使用的格式: %Y-4位数年份 %y-2位数年份 %m-月份 %d-天 实现自定义日期的步骤: 定义日期格式: myFmt = DateFormatter("%m/%d"),这个日期格式是月/日,所以它看起来像这样: 10/05,代表10月5日 调用set_major_formatter()方法: ax.xaxis.set_major_formatter(myFmt) 将上面定义的日期格式应用于绘图空间中 # Plot the data fig, ax = plt.subplots(figsize=(10,6)) ax.scatter(precip_boulder_AugOct.index.values, precip_boulder_AugOct['DAILY_PRECIP'].values, color='purple') ax.set(xlabel="Date", ylabel="Precipitation (Inches)", title="Daily Precipitation (inches)\nBoulder, Colorado 2013") # Define the date format date_form = DateFormatter("%m/%d") ax.xaxis.set_major_formatter(date_form) 3.3 X轴的日期刻度 特定的时间刻度可以沿着x轴添加,例如:大的刻度可以表示每个新的工作周的开始,小的刻度可以表示每个工作日 函数xaxis.set_major_locator()控制大刻度的位置,函数xaxis.set_minor_locator控制小刻度 # Plot the data fig, ax = plt.subplots(figsize=(10,6)) ax.scatter(precip_boulder_AugOct.index.values, precip_boulder_AugOct['DAILY_PRECIP'].values, color='purple') ax.set(xlabel="Date", ylabel="Precipitation (Inches)", title="Daily Precipitation (inches)\nBoulder, Colorado 2013") # 定义日期格式 date_form = DateFormatter("%m/%d") ax.xaxis.set_major_formatter(date_form) # 确保每隔一周刻度减小一次 ax.xaxis.set_major_locator(mdates.WeekdayLocator(interval=1)) # ax.xaxis.set_minor_locator(mdates.DayLocator(1)) 参考资料: https://www.earthdatascience.org/courses/scientists-guide-to-plotting-data-in-python-textbook/

优秀的个人博客,低调大师

探秘 Dubbo 的度量统计基础设施 - Dubbo Metrics

对服务进行实时监控,了解服务当前的运行指标和健康状态,是微服务体系中不可或缺的环节。Metrics 作为微服务的重要组件,为服务的监控提供了全面的数据基础。近日,Dubbo Metrics 发布了2.0.1版本,本文将为您探秘 Dubbo Metrics 的起源,及 7 大改进。 Dubbo Metrics 的起源 Dubbo Metrics(原Alibaba Metrics)是阿里巴巴集团内部广泛使用的度量埋点基础类库,有 Java 和 Node.js 两个版本,目前开源的是 Java 版本。内部版本诞生于2016年,经历过近三年的发展和双十一的考验,已经成为阿里巴巴集团内部微服务监控度量的事实标准,覆盖了从系统、JVM、中间件到应用各层的度量,并且在命名规则、数据格式、埋点方式和计算规则等方面,形成了一套统一的规范。 Dubbo M

优秀的个人博客,低调大师

统计数字】算法题解析

这是一道来自LintCode的算法题目,本文用C++来解答这道题,链接为: https://www.lintcode.com/problem/digit-counts/description 题目描述 计算数字k在0到n中的出现的次数,k可能是0~9的一个值。 样例 例如n=12,k=1,在 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],我们发现1出现了5次 (1, 10, 11, 12) 思路 当k=1时,对于整数1111,一共出现了4次,也就是判断每一位上的数字是不是1, 数字1111共有4位,就要对其判断4次,从个位开始,除以10取余数即可。 按照这个思路,代码如下: 代码 #include #include <sys/time.h> class Solution { public: /** * @param k: An integer * @param n: An integer * @return: An integer denote the count of digit k in 1..n */ int digitCounts(int k, int n) { // write your code here int count = 0; for (int i=0; i<=n; i++) { int t = i; while(t > 9) { int gewei = t % 10; if(gewei == k) count ++; t = t / 10; } if (t == k) count++; } return count; } }; 如果你有其它更好的算法来解决这个问题,欢迎留言讨论。 文章来自于猿人学博客:Python教程

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册