python时间序列可视化_TOP50 Python可视化经典案例下(附源码,建议收藏)

昨天行哥给大家统计了数据可视化前30张图表代码和案例给大家,今天把分享Python可视化案例TOP 50下,如果想转行做数据分析,这两篇推文强烈建议收藏,对于学习有任何问题都可以点击阅读原文向行哥提问哦

5.组成

5.1华夫饼图

5.2 饼图

5.3 树状图

5.4 条形图

6 时间序列

6.1时间序列图

6.2 带有标记的时间序列图

6.3自相关(ACF)和部分自相关(PACF)图

6.4 交叉相关图

6.5 时间序列分解图

6.6 多时间序列图

6.7 双y轴图

6.8 具有误差带的时间序列

6.9 堆积面积图

6.10 区域图(未堆叠)

6.11 日历热图

6.12 季节性图

7 分组

7.1 树状图

7.2 聚类图

7.3 安德鲁斯曲线

7.4 平行坐标图

5.组成

5.1华夫饼图

waffle可以使用该pywaffle软件包创建该图表,并用于显示较大人群中各组的组成。

#! pip install pywaffle

# Reference: https://stackoverflow.com/questions/41400136/how-to-do-waffle-charts-in-python-square-piechart

from pywaffle import Waffle

# Import

df_raw = pd.read_csv("data/mpg_ggplot2.csv")

# Prepare Data

df = df_raw.groupby('class').size().reset_index(name='counts')

n_categories = df.shape[0]

colors = [plt.cm.inferno_r(i/float(n_categories)) for i in range(n_categories)]

# Draw Plot and Decorate

fig = plt.figure(

FigureClass=Waffle,

plots={

'111': {

'values': df['counts'],

'labels': ["{0} ({1})".format(n[0], n[1]) for n in df[['class', 'counts']].itertuples()],

'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.05, 1), 'fontsize': 12},

'title': {'label': '# Vehicles by Class', 'loc': 'center', 'fontsize':18}

},

},

rows=7,

colors=colors,

figsize=(16, 9)

)

#! pip install pywaffle

from pywaffle import Waffle

# Import

# df_raw = pd.read_csv("data/mpg_ggplot2.csv")

# Prepare Data

# By Class Data

df_class = df_raw.groupby('class').size().reset_index(name='counts_class')

n_categories = df_class.shape[0]

colors_class = [plt.cm.Set3(i/float(n_categories)) for i in range(n_categories)]

# By Cylinders Data

df_cyl = df_raw.groupby('cyl').size().reset_index(name='counts_cyl')

n_categories = df_cyl.shape[0]

colors_cyl = [plt.cm.Spectral(i/float(n_categories)) for i in range(n_categories)]

# By Make Data

df_make = df_raw.groupby('manufacturer').size().reset_index(name='counts_make')

n_categories = df_make.shape[0]

colors_make = [plt.cm.tab20b(i/float(n_categories)) for i in range(n_categories)]

# Draw Plot and Decorate

fig = plt.figure(

FigureClass=Waffle,

plots={

'311': {

'values': df_class['counts_class'],

'labels': ["{1}".format(n[0], n[1]) for n in df_class[['class', 'counts_class']].itertuples()],

'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.05, 1), 'fontsize': 12, 'title':'Class'},

'title': {'label': '# Vehicles by Class', 'loc': 'center', 'fontsize':18},

'colors': colors_class

},

'312': {

'values': df_cyl['counts_cyl'],

'labels': ["{1}".format(n[0], n[1]) for n in df_cyl[['cyl', 'counts_cyl']].itertuples()],

'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.05, 1), 'fontsize': 12, 'title':'Cyl'},

'title': {'label': '# Vehicles by Cyl', 'loc': 'center', 'fontsize':18},

'colors': colors_cyl

},

'313': {

'values': df_make['counts_make'],

'labels': ["{1}".format(n[0], n[1]) for n in df_make[['manufacturer', 'counts_make']].itertuples()],

'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.05, 1), 'fontsize': 12, 'title':'Manufacturer'},

'title': {'label': '# Vehicles by Make', 'loc': 'center', 'fontsize':18},

'colors': colors_make

}

},

rows=9,

figsize=(16, 14)

)

5.2 饼图

饼图是显示组组成的经典方法。但是,如今一般不建议使用它,因为馅饼部分的面积有时可能会引起误解。因此,如果要使用饼图,强烈建议明确写下饼图各部分的百分比或数字。

# Import

df_raw = pd.read_csv("data/mpg_ggplot2.csv")

# Prepare Data

df = df_raw.groupby('class').size()

# Make the plot with pandas

df.plot(kind='pie', subplots=True, figsize=(8, 8), dpi= 80)

plt.title("Pie Chart of Vehicle Class - Bad")

plt.ylabel("")

plt.show()

# Import

df_raw = pd.read_csv("data/mpg_ggplot2.csv")

# Prepare Data

df = df_raw.groupby('class').size().reset_index(name='counts')

# Draw Plot

fig, ax = plt.subplots(figsize=(12, 7), subplot_kw=dict(aspect="equal"), dpi= 80)

data = df['counts']

categories = df['class']

explode = [0,0,0,0,0,0.1,0]

def func(pct, allvals):

absolute = int(pct/100.*np.sum(allvals))

return "{:.1f}% ({:d} )".format(pct, absolute)

wedges, texts, autotexts = ax.pie(data,

autopct=lambda pct: func(pct, data),

textprops=dict(color="w"),

colors=plt.cm.Dark2.colors,

startangle=140,

explode=explode)

# Decoration

ax.legend(wedges, categories, title="Vehicle Class", loc="center left", bbox_to_anchor=(1, 0, 0.5, 1))

plt.setp(autotexts, size=10, weight=700)

ax.set_title("Class of Vehicles: Pie Chart")

plt.show()

5.3 树状图

树形图类似于饼形图,并且可以更好地完成工作,而不会误导每个组的贡献。

# pip install squarify

import squarify

# Import Data

df_raw = pd.read_csv("data/mpg_ggplot2.csv")

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
项目概述:本项目是一项基于Python语言的机器学习天气预测和数据可视化课程设计。项目主要运用Python编程语言,结合HTML进行前端展示,共包含24个文件,其中包含了12张jpg格式的像文件,4个Python源代码文件,4个csv格式的数据文件,以及用于版本控制的.gitignore文件、项目说明的md文件、数据序列化的pkl文件和1个HTML文件。 项目目的:通过机器学习算法对天气数据进行处理和分析,实现天气的预测功能,并通过数据可视化技术将复杂的气象数据以直观的方式展现给用户。 技术构成: - Python:核心编程语言,用于实现机器学习算法及数据处理。 - HTML:用于构建前端展示页面,提供用户友好的交互界面。 文件结构概览: - 片文件:12个jpg文件,用于展示数据可视化结果。 - 源代码文件:4个py文件,包含机器学习模型构建、数据预处理等核心逻辑。 - 数据文件:4个csv文件,存储原始天气数据和预测结果。 - 配置文件:.gitignore文件,用于定义哪些文件和目录应该被Git忽略。 - 项目文档:1个md文件,包含项目详细说明和操作指南。 - 数据序列化文件:1个pkl文件,用于保存模型和数据的序列化格式。 - 前端页面:1个html文件,用于展示天气预测结果和交互界面。 本项目不仅提供了一种高效的天气预测解决方案,同时也展示了Python在数据处理、机器学习以及数据可视化方面的强大能力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值