欢迎关注 『pandas_alive绘制竞赛动图』 专栏,持续更新中
欢迎关注 『pandas_alive绘制竞赛动图』 专栏,持续更新中
资源文件下载:
专栏学习说明(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)
所有效果图预览:
效果图展示(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)
环境配置:
环境配置与检测(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)
在一张gif图中显示多张表。
plots=[animated_bar_chart, animated_line_chart],
- 两个表放进一个列表中,参数plots放入的是要被绘制进主图的两张子图
enable_progress_bar=True- 是否在生成图片时显示生成图片的进度,以一个进度条的方式呈现
关于如何自定义多张表之间的距离,标题等功能,在下一节中具体说明
【8.城市人口(测试代码+数据集+绘图参数解析)】
保存文件名为 covid19.csv
,建议码云下载,否则可能出现编码问题
date,Belgium,Brazil,Canada,China,France,Germany,India,Indonesia,Iran,Ireland,Italy,Mexico,Netherlands,Portugal,Spain,Sweden,Switzerland,Turkey,USA,United Kingdom
2020-02-26,,,,2717.0,2.0,,,,19.0,,12.0,,,,,,,,,
2020-02-27,,,,2746.0,2.0,,,,26.0,,17.0,,,,,,,,,
2020-02-28,,,,2790.0,2.0,,,,34.0,,21.0,,,,,,,,,
2020-02-29,,,,2837.0,2.0,,,,43.0,,29.0,,,,,,,,1.0,
2020-03-01,,,,2872.0,2.0,,,,54.0,,34.0,,,,,,,,1.0,
2020-03-02,,,,2914.0,3.0,,,,66.0,,52.0,,,,,,,,6.0,
2020-03-03,,,,2947.0,4.0,,,,77.0,,79.0,,,,1.0,,,,7.0,
2020-03-04,,,,2983.0,4.0,,,,92.0,,107.0,,,,2.0,,,,11.0,
2020-03-05,,,,3015.0,6.0,,,,107.0,,148.0,,,,3.0,,1.0,,12.0,1.0
2020-03-06,,,,3044.0,9.0,,,,124.0,,197.0,,1.0,,5.0,,1.0,,14.0,2.0
2020-03-07,,,,3072.0,11.0,,,,145.0,,233.0,,1.0,,10.0,,1.0,,17.0,2.0
2020-03-08,,,,3100.0,19.0,,,,194.0,,366.0,,3.0,,17.0,,2.0,,21.0,3.0
2020-03-09,,,1.0,3123.0,19.0,2.0,,,237.0,,463.0,,3.0,,28.0,,2.0,,22.0,4.0
2020-03-10,,,1.0,3139.0,33.0,2.0,,,291.0,,631.0,,4.0,,35.0,,3.0,,28.0,6.0
2020-03-11,3.0,,1.0,3161.0,48.0,3.0,1.0,1.0,354.0,1.0,827.0,,5.0,,54.0,1.0,4.0,,32.0,8.0
2020-03-12,3.0,,1.0,3172.0,48.0,3.0,1.0,1.0,429.0,1.0,1000.0,,5.0,,55.0,1.0,4.0,,40.0,8.0
2020-03-13,3.0,,1.0,3180.0,79.0,7.0,2.0,4.0,514.0,1.0,1266.0,,10.0,,133.0,1.0,11.0,,48.0,8.0
2020-03-14,4.0,,1.0,3193.0,91.0,9.0,2.0,5.0,611.0,2.0,1441.0,,12.0,,195.0,2.0,13.0,,54.0,21.0
2020-03-15,4.0,,1.0,3203.0,91.0,11.0,2.0,5.0,724.0,2.0,1809.0,,20.0,,289.0,3.0,14.0,,60.0,21.0
2020-03-16,5.0,,4.0,3217.0,149.0,17.0,2.0,5.0,853.0,2.0,2158.0,,24.0,,342.0,6.0,14.0,,84.0,56.0
2020-03-17,10.0,1.0,5.0,3230.0,149.0,24.0,3.0,5.0,988.0,2.0,2503.0,,43.0,1.0,533.0,7.0,27.0,1.0,107.0,56.0
2020-03-18,14.0,3.0,8.0,3241.0,149.0,28.0,3.0,19.0,1135.0,2.0,2978.0,,58.0,2.0,623.0,10.0,28.0,1.0,143.0,72.0
2020-03-19,21.0,6.0,9.0,3249.0,244.0,44.0,4.0,25.0,1284.0,3.0,3405.0,1.0,77.0,3.0,830.0,11.0,41.0,3.0,209.0,138.0
2020-03-20,37.0,11.0,12.0,3253.0,451.0,67.0,5.0,32.0,1433.0,3.0,4032.0,1.0,107.0,6.0,1043.0,16.0,54.0,4.0,260.0,178.0
2020-03-21,67.0,15.0,19.0,3259.0,563.0,84.0,6.0,38.0,1556.0,3.0,4825.0,2.0,137.0,12.0,1375.0,20.0,75.0,9.0,320.0,234.0
2020-03-22,75.0,25.0,21.0,3274.0,676.0,94.0,7.0,48.0,1685.0,4.0,5476.0,2.0,180.0,14.0,1772.0,21.0,98.0,30.0,427.0,282.0
2020-03-23,88.0,34.0,25.0,3274.0,862.0,123.0,10.0,49.0,1812.0,6.0,6077.0,3.0,214.0,23.0,2311.0,25.0,120.0,37.0,552.0,336.0
2020-03-24,122.0,46.0,26.0,3281.0,1102.0,157.0,10.0,55.0,1934.0,7.0,6820.0,4.0,277.0,33.0,2808.0,36.0,122.0,44.0,706.0,423.0
2020-03-25,178.0,59.0,30.0,3285.0,1333.0,206.0,12.0,58.0,2077.0,9.0,7503.0,5.0,357.0,43.0,3647.0,62.0,153.0,59.0,943.0,466.0
2020-03-26,220.0,77.0,38.0,3291.0,1698.0,267.0,20.0,78.0,2234.0,19.0,8215.0,6.0,435.0,60.0,4365.0,77.0,191.0,75.0,1210.0,580.0
2020-03-27,289.0,92.0,54.0,3296.0,1997.0,342.0,20.0,87.0,2378.0,22.0,9134.0,8.0,547.0,76.0,5138.0,105.0,231.0,92.0,1582.0,761.0
2020-03-28,353.0,111.0,61.0,3299.0,2317.0,433.0,24.0,102.0,2517.0,36.0,10023.0,12.0,640.0,100.0,5982.0,105.0,264.0,108.0,2182.0,1021.0
2020-03-29,431.0,136.0,64.0,3304.0,2611.0,533.0,27.0,114.0,2640.0,46.0,10779.0,16.0,772.0,119.0,6803.0,110.0,300.0,131.0,2566.0,1231.0
2020-03-30,513.0,159.0,80.0,3308.0,3030.0,645.0,32.0,122.0,2757.0,54.0,11591.0,20.0,865.0,140.0,7716.0,146.0,359.0,168.0,3112.0,1411.0
2020-03-31,705.0,201.0,101.0,3309.0,3532.0,775.0,35.0,136.0,2898.0,71.0,12428.0,28.0,1040.0,160.0,8464.0,180.0,433.0,214.0,4039.0,1793.0
2020-04-01,828.0,240.0,109.0,3316.0,4414.0,920.0,58.0,157.0,3036.0,85.0,13155.0,29.0,1175.0,187.0,9387.0,239.0,488.0,277.0,4995.0,2357.0
2020-04-02,1011.0,324.0,139.0,3322.0,5398.0,1107.0,72.0,170.0,3160.0,98.0,13915.0,37.0,1341.0,209.0,10348.0,308.0,536.0,356.0,6294.0,2926.0
2020-04-03,1143.0,359.0,179.0,3326.0,6520.0,1275.0,72.0,181.0,3294.0,120.0,14681.0,50.0,1490.0,246.0,11198.0,358.0,591.0,425.0,7418.0,3611.0
2020-04-04,1283.0,445.0,218.0,3330.0,7574.0,1444.0,86.0,191.0,3452.0,137.0,15362.0,60.0,1656.0,266.0,11947.0,373.0,666.0,501.0,8387.0,4320.0
2020-04-05,1447.0,486.0,259.0,3333.0,8093.0,1584.0,99.0,198.0,3603.0,158.0,15887.0,79.0,1771.0,295.0,12641.0,401.0,715.0,574.0,9489.0,4943.0
2020-04-06,1632.0,564.0,339.0,3335.0,8926.0,1810.0,136.0,209.0,3739.0,174.0,16523.0,94.0,1874.0,311.0,13341.0,477.0,765.0,649.0,10783.0,5385.0
2020-04-07,2035.0,686.0,375.0,3335.0,10343.0,2016.0,150.0,221.0,3872.0,210.0,17127.0,125.0,2108.0,345.0,14045.0,591.0,821.0,725.0,12798.0,6171.0
2020-04-08,2240.0,819.0,407.0,3337.0,10887.0,2349.0,178.0,240.0,3993.0,235.0,17669.0,141.0,2255.0,380.0,14792.0,687.0,895.0,812.0,14704.0,7111.0
2020-04-09,2523.0,950.0,503.0,3339.0,12228.0,2607.0,226.0,280.0,4110.0,263.0,18279.0,174.0,2403.0,409.0,15447.0,793.0,948.0,908.0,16553.0,7993.0
2020-04-10,3019.0,1057.0,557.0,3340.0,13215.0,2767.0,246.0,306.0,4232.0,287.0,18849.0,194.0,2520.0,435.0,16081.0,870.0,1002.0,1006.0,18595.0,8974.0
2020-04-11,3346.0,1124.0,654.0,3343.0,13851.0,2894.0,288.0,327.0,4357.0,320.0,19468.0,233.0,2653.0,470.0,16606.0,887.0,1036.0,1101.0,20471.0,9892.0
2020-04-12,3600.0,1223.0,714.0,3343.0,14412.0,3022.0,331.0,373.0,4474.0,334.0,19899.0,273.0,2747.0,504.0,17209.0,899.0,1106.0,1198.0,22032.0,10629.0
2020-04-13,3903.0,1328.0,779.0,3345.0,14986.0,3194.0,358.0,399.0,4585.0,365.0,20465.0,296.0,2833.0,535.0,17756.0,919.0,1138.0,1296.0,23546.0,11347.0
2020-04-14,4157.0,1532.0,899.0,3345.0,15748.0,3294.0,393.0,459.0,4683.0,406.0,21067.0,332.0,2955.0,567.0,18056.0,1033.0,1174.0,1403.0,25854.0,12129.0
2020-04-15,4440.0,1736.0,1006.0,3346.0,17188.0,3804.0,405.0,469.0,4777.0,444.0,21645.0,406.0,3145.0,599.0,18708.0,1203.0,1239.0,1518.0,28341.0,12894.0
2020-04-16,4857.0,1924.0,1257.0,3346.0,17941.0,4052.0,448.0,496.0,4869.0,486.0,22170.0,449.0,3327.0,629.0,19315.0,1333.0,1281.0,1643.0,32933.0,13759.0
2020-04-17,5163.0,2141.0,1354.0,4636.0,18703.0,4352.0,486.0,520.0,4958.0,530.0,22745.0,486.0,3471.0,657.0,20002.0,1400.0,1327.0,1769.0,36790.0,14607.0
2020-04-18,5453.0,2354.0,1399.0,4636.0,19345.0,4459.0,521.0,535.0,5031.0,571.0,23227.0,546.0,3613.0,687.0,20043.0,1511.0,1368.0,1890.0,38671.0,15498.0
2020-04-19,5683.0,2462.0,1563.0,4636.0,19744.0,4586.0,559.0,582.0,5118.0,610.0,23660.0,650.0,3697.0,714.0,20453.0,1540.0,1393.0,2017.0,40664.0,16095.0
2020-04-20,5828.0,2587.0,1725.0,4636.0,20292.0,4862.0,592.0,590.0,5209.0,687.0,24114.0,686.0,3764.0,735.0,20852.0,1580.0,1429.0,2140.0,42097.0,16550.0
2020-04-21,5998.0,2741.0,1908.0,4636.0,20829.0,5033.0,645.0,616.0,5297.0,730.0,24648.0,712.0,3929.0,762.0,21282.0,1765.0,1478.0,2259.0,44447.0,17378.0
2020-04-22,6262.0,2906.0,2075.0,4636.0,21373.0,5279.0,681.0,635.0,5391.0,769.0,25085.0,857.0,4068.0,785.0,21717.0,1937.0,1509.0,2376.0,46628.0,18151.0
# @Time : 2022/1/12 22:13
# @Author : 南黎
# @FileName: 7.多个图表.py
import pandas as pd
######显示中文宋体字体导入,如果使用中文加上这段代码######
import matplotlib as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
#####################################################
import pandas_alive
df = pd.read_csv("数据源data/covid19.csv", index_col=0, parse_dates=[0], thousands=',')
# 生成第一个表
animated_line_chart = df.diff().fillna(0).plot_animated(
title='发现你走远了——子图1',
kind='line',
period_label=False,
add_legend=False
)
# 生成第二个表
animated_bar_chart = df.plot_animated(
title='发现你走远了——子图2',
n_visible=10
)
# 最后保存图片的时候,用一个列表同时装入2个表
pandas_alive.animate_multiple_plots(
filename='7.多个图表.gif',
plots=[animated_bar_chart, animated_line_chart], # 两个表放进一个列表中
title='发现你走远了——7.多个图表',
enable_progress_bar=True # 是否在生成图片时显示生成图片的进度,以一个进度条的方式呈现
)
版权声明:
发现你走远了@mzh原创作品,转载必须标注原文链接
Copyright 2022 mzh
Crated:2022-1-13
我折腾了一星期,梳理了很多入门小白避雷的方法,还会继续更新,如果看了对你有帮助,希望得到大家的点赞收藏支持!
(毕竟时短间学完太难了,建议放进收藏夹吃灰
)
欢迎关注 『pandas_alive绘制竞赛动图』 专栏,持续更新中
欢迎关注 『pandas_alive绘制竞赛动图』 专栏,持续更新中
【一、效果图展示(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)】
【二、专栏学习说明(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)】
【三、环境配置与检测(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)】
【四、数据集说明(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)】
【五、常见问题(配置好的venv虚拟环境+拿来即用测试代码+测试数据集+参数api解析)】
【1.条形图(测试代码+数据集+绘图参数解析)】
【2.折线图(测试代码+数据集+绘图参数解析)】
【3.散点图(测试代码+数据集+绘图参数解析)】
【4.饼状图(测试代码+数据集+绘图参数解析)】
【5.气泡图(测试代码+数据集+绘图参数解析)】
【6.地理空间图(测试代码+数据集+绘图参数解析)】
【7.多个图表(测试代码+数据集+绘图参数解析)】
【8.城市人口(测试代码+数据集+绘图参数解析)】
【9.G7国家的预期寿命(测试代码+数据集+绘图参数解析)】
【10.新南威尔士州 COVID 可视化(测试代码+数据集+绘图参数解析)】
【更多内容敬请期待】