当前位置: 首页 > news >正文

如何做好企业网站建设网站开发成本预算价目表

如何做好企业网站建设,网站开发成本预算价目表,做电影下载网站还赚钱吗,教育培训排行榜前十名来源#xff1a;机器之心原文链接#xff1a;https://towardsdatascience.com/learn-how-to-create-animated-graphs-in-python-fce780421afe在读技术博客的过程中#xff0c;我们会发现那些能够把知识、成果讲透的博主很多都会做动态图表。他们的图是怎么做的#xff1f;难… 来源机器之心原文链接https://towardsdatascience.com/learn-how-to-create-animated-graphs-in-python-fce780421afe在读技术博客的过程中我们会发现那些能够把知识、成果讲透的博主很多都会做动态图表。他们的图是怎么做的难度大吗这篇文章就介绍了 Python 中一种简单的动态图表制作方法。数据暴增的年代数据科学家、分析师在被要求对数据有更深的理解与分析的同时还需要将结果有效地传递给他人。如何让目标听众更直观地理解当然是将数据可视化啊而且最好是动态可视化。本文将以线型图、条形图和饼图为例系统地讲解如何让你的数据图表动起来。这些动态图表是用什么做的接触过数据可视化的同学应该对 Python 里的 Matplotlib 库并不陌生。它是一个基于 Python 的开源数据绘图包仅需几行代码就可以帮助开发者生成直方图、功率谱、条形图、散点图等。这个库里有个非常实用的扩展包——FuncAnimation可以让我们的静态图表动起来。FuncAnimation 是 Matplotlib 库中 Animation 类的一部分后续会展示多个示例。如果是首次接触你可以将这个函数简单地理解为一个 While 循环不停地在 “画布” 上重新绘制目标数据图。如何使用 FuncAnimation这个过程始于以下两行代码import matplotlib.animation as anianimator  ani.FuncAnimation(fig, chartfunc, interval  100)从中我们可以看到 FuncAnimation 的几个输入fig 是用来 「绘制图表」的 figure 对象chartfunc 是一个以数字为输入的函数其含义为时间序列上的时间interval 这个更好理解是帧之间的间隔延迟以毫秒为单位默认值为 200。这是三个关键输入当然还有更多可选输入感兴趣的读者可查看原文档这里不再赘述。下一步要做的就是将数据图表参数化从而转换为一个函数然后将该函数时间序列中的点作为输入设置完成后就可以正式开始了。在开始之前依旧需要确认你是否对基本的数据可视化有所了解。也就是说我们先要将数据进行可视化处理再进行动态处理。按照以下代码进行基本调用。另外这里将采用大型流行病的传播数据作为案例数据(包括每天的死亡人数)。import matplotlib.animation as aniimport matplotlib.pyplot as pltimport numpy as npimport pandas as pdurl  https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csvdf  pd.read_csv(url, delimiter,, headerinfer)df_interest  df.loc[    df[Country/Region].isin([United Kingdom, US, Italy, Germany])     df[Province/State].isna()]df_interest.rename(    indexlambda x: df_interest.at[x, Country/Region], inplaceTrue)df1  df_interest.transpose()df1  df1.drop([Province/State, Country/Region, Lat, Long])df1  df1.loc[(df1 ! 0).any(1)]df1.index  pd.to_datetime(df1.index)绘制三种常见动态图表动态曲线图如下所示首先需要做的第一件事是定义图的各项这些基础项设定之后就会保持不变。它们包括创建 figure 对象x 标和 y 标设置线条颜色和 figure 边距等import numpy as npimport matplotlib.pyplot as pltcolor  [red, green, blue, orange]fig  plt.figure()plt.xticks(rotation45, haright, rotation_modeanchor) #rotate the x-axis valuesplt.subplots_adjust(bottom  0.2, top  0.9) #ensuring the dates (on the x-axis) fit in the screenplt.ylabel(No of Deaths)plt.xlabel(Dates)接下来设置 curve 函数进而使用 .FuncAnimation 让它动起来def buildmebarchart(iint):    plt.legend(df1.columns)    p  plt.plot(df1[:i].index, df1[:i].values) #note it only returns the dataset, up to the point i    for i in range(0,4):        p[i].set_color(color[i]) #set the colour of each curveimport matplotlib.animation as anianimator  ani.FuncAnimation(fig, buildmebarchart, interval  100)plt.show()动态饼状图可以观察到其代码结构看起来与线型图并无太大差异但依旧有细小的差别。import numpy as npimport matplotlib.pyplot as pltfig,ax  plt.subplots()explode[0.01,0.01,0.01,0.01] #pop out each slice from the piedef getmepie(i):    def absolute_value(val): #turn % back to a number        a   np.round(val/100.*df1.head(i).max().sum(), 0)        return int(a)    ax.clear()    plot  df1.head(i).max().plot.pie(ydf1.columns,autopctabsolute_value, label,explode  explode, shadow  True)    plot.set_title(Total Number of Deaths\n  str(df1.index[min( i, len(df1.index)-1 )].strftime(%y-%m-%d)), fontsize12)import matplotlib.animation as anianimator  ani.FuncAnimation(fig, getmepie, interval  200)plt.show()主要区别在于动态饼状图的代码每次循环都会返回一组数值但在线型图中返回的是我们所在点之前的整个时间序列。返回时间序列通过 df1.head(i) 来实现而. max()则保证了我们仅获得最新的数据因为流行病导致死亡的总数只有两种变化维持现有数量或持续上升。df1.head(i).max()动态条形图创建动态条形图的难度与上述两个案例并无太大差别。在这个案例中作者定义了水平和垂直两种条形图读者可以根据自己的实际需求来选择图表类型并定义变量栏。fig  plt.figure()bar  def buildmebarchart(iint):    iv  min(i, len(df1.index)-1) #the loop iterates an extra one time, which causes the dataframes to go out of bounds. This was the easiest (most lazy) way to solve this :)    objects  df1.max().index    y_pos  np.arange(len(objects))    performance  df1.iloc[[iv]].values.tolist()[0]    if bar  vertical:        plt.bar(y_pos, performance, aligncenter, color[red, green, blue, orange])        plt.xticks(y_pos, objects)        plt.ylabel(Deaths)        plt.xlabel(Countries)        plt.title(Deaths per Country \n  str(df1.index[iv].strftime(%y-%m-%d)))    else:        plt.barh(y_pos, performance, aligncenter, color[red, green, blue, orange])        plt.yticks(y_pos, objects)        plt.xlabel(Deaths)        plt.ylabel(Countries)animator  ani.FuncAnimation(fig, buildmebarchart, interval100)plt.show()保存动画图在制作完成后存储这些动态图就非常简单了可直接使用以下代码animator.save(rC:\temp\myfirstAnimation.gif)感兴趣的读者如想获得详细信息可参考https://matplotlib.org/3.1.1/api/animation_api.html。
http://www.huolong8.cn/news/122044/

相关文章:

  • 做公司网站的公司有哪些分销工具
  • 我要建立网站平面设计图网站
  • 广州网站建设推广专家团队哪个网站可以免费做H5
  • 网络推广网站推广方法做博客网站的空间容量需要多少
  • dedecms建站教程学校网站制作多少钱
  • 代理注册公司有什么风险网站主关键词如何优化
  • 手机阅读网站开发原因中国机械设备制造网
  • 怎么样可以设计网站做网站建设需要做哪些工作室
  • 做网站域名福州网页建站维护有哪些
  • 网站ui设计给用户提交什么门户网站app有哪些
  • 免费建设电影网站浙江职业能力建设网站
  • 台州卫浴网站建设近三天时政热点
  • 怎么建正规网站asp iis设置网站路径
  • 在线做静态头像的网站企业网站建设需要哪些资料
  • 建网站业务员标志设计ppt课件
  • 导航网站前端模板下载先申请网站空间
  • 北京正规网站建设调整网站收录入口申请查询
  • 网站地图有哪些网址道路运输电子证照
  • perl 网站开发网站收录变少
  • 招聘网站模板页深圳网络营销外包好吗
  • 坪地网站建设信息社交新零售
  • 广州手机网站设计电商网站备案
  • 一开始用php做网站建筑行业信息查询平台
  • 河南省建协网官方网站网站开发任务需求书
  • 搜狗提交网站收录入口重庆商城网站制作报价
  • 做网站全过程广告推广语
  • 南京高端网站建设哪家好上海建设学校网站
  • 学院网站建设与管理办法怎么建设一个优秀的网站
  • 色彩 导航网站crm管理系统功能
  • 网站建设 不需要见面网站建设要注意些什么