将时间序列数据可视化为热图

问题描述 投票:0回答:2

我想将不同的空间天气指数可视化为热图或图像。目标是在 y 轴上绘制小时数,在 x 轴上绘制日期,并将空间天气的强度绘制为每天的值。请看一下给定的图以了解我到底想要实现什么。

figure that I want to achieve

我的目标:

我想从 pcolormesh、pcolor、imshow 或 seaborn 的热图中制作任何图形。

记住,KP > 40 = 类似的风暴,dst < -30 = storm.

地震日是2020/09/01

我不知道如何将日期时间/小时和值绘制为 pcolormesh、imshow、pcolor 或 heatmap。我很困惑如何去做。

这是我到目前为止所做的!

X,Y = np.meshgrid(sw_indices.index.day, sw_indices.index.hour)
from scipy.interpolate import griddata
Z = griddata((sw_indices.index.day, sw_indices.index.hour), 
sw_indices.kp, (X,Y), method="nearest")

fig, ax = plt.subplots()
ax.pcolormesh(X, Y, Z)

这是完整的数据文件:https://drive.google.com/file/d/1cz5i2n6zGGsQVDejRpteai8Zs07_58vL/view?usp=sharing

以下是文件的顶部和底部 315 行(适合问题)。

,year,doy,hr,kp,ssn,dst,f10_7
2020-08-02 00:00:00,YEAR,DOY,HR,1,2,3,4.0
2020-08-02 01:00:00,2020,215,0,3,15,18,74.9
2020-08-02 02:00:00,2020,215,1,3,15,16,74.9
2020-08-02 03:00:00,2020,215,2,3,15,10,74.9
2020-08-02 04:00:00,2020,215,3,7,15,7,74.9
2020-08-02 05:00:00,2020,215,4,7,15,6,74.9
2020-08-02 06:00:00,2020,215,5,7,15,11,74.9
2020-08-02 07:00:00,2020,215,6,10,15,17,74.9
2020-08-02 08:00:00,2020,215,7,10,15,14,74.9
2020-08-02 09:00:00,2020,215,8,10,15,19,74.9
2020-08-02 10:00:00,2020,215,9,27,15,22,74.9
2020-08-02 11:00:00,2020,215,10,27,15,21,74.9
2020-08-02 12:00:00,2020,215,11,27,15,12,74.9
2020-08-02 13:00:00,2020,215,12,33,15,-2,74.9
2020-08-02 14:00:00,2020,215,13,33,15,-14,74.9
2020-08-02 15:00:00,2020,215,14,33,15,-12,74.9
2020-08-02 16:00:00,2020,215,15,30,15,-14,74.9
2020-08-02 17:00:00,2020,215,16,30,15,-14,74.9
2020-08-02 18:00:00,2020,215,17,30,15,-7,74.9
2020-08-02 19:00:00,2020,215,18,20,15,0,74.9
2020-08-02 20:00:00,2020,215,19,20,15,3,74.9
2020-08-02 21:00:00,2020,215,20,20,15,9,74.9
2020-08-02 22:00:00,2020,215,21,30,15,-3,74.9
2020-08-02 23:00:00,2020,215,22,30,15,-8,74.9
2020-08-03 00:00:00,2020,215,23,30,15,-5,74.9
2020-08-03 01:00:00,2020,216,0,33,11,-2,74.8
2020-08-03 02:00:00,2020,216,1,33,11,-1,74.8
2020-08-03 03:00:00,2020,216,2,33,11,-2,74.8
2020-08-03 04:00:00,2020,216,3,33,11,-19,74.8
2020-08-03 05:00:00,2020,216,4,33,11,-17,74.8
2020-08-03 06:00:00,2020,216,5,33,11,-16,74.8
2020-08-03 07:00:00,2020,216,6,30,11,-22,74.8
2020-08-03 08:00:00,2020,216,7,30,11,-20,74.8
2020-08-03 09:00:00,2020,216,8,30,11,-28,74.8
2020-08-03 10:00:00,2020,216,9,27,11,-30,74.8
2020-08-03 11:00:00,2020,216,10,27,11,-18,74.8
2020-08-03 12:00:00,2020,216,11,27,11,-12,74.8
2020-08-03 13:00:00,2020,216,12,23,11,-7,74.8
2020-08-03 14:00:00,2020,216,13,23,11,-7,74.8
2020-08-03 15:00:00,2020,216,14,23,11,-9,74.8
2020-08-03 16:00:00,2020,216,15,33,11,-8,74.8
2020-08-03 17:00:00,2020,216,16,33,11,-3,74.8
2020-08-03 18:00:00,2020,216,17,33,11,-7,74.8
2020-08-03 19:00:00,2020,216,18,30,11,-13,74.8
2020-08-03 20:00:00,2020,216,19,30,11,-16,74.8
2020-08-03 21:00:00,2020,216,20,30,11,-16,74.8
2020-08-03 22:00:00,2020,216,21,33,11,-15,74.8
2020-08-03 23:00:00,2020,216,22,33,11,-21,74.8
2020-08-04 00:00:00,2020,216,23,33,11,-18,74.8
2020-08-04 01:00:00,2020,217,0,20,11,-14,75.1
2020-08-04 02:00:00,2020,217,1,20,11,-13,75.1
2020-08-04 03:00:00,2020,217,2,20,11,-18,75.1
2020-08-04 04:00:00,2020,217,3,33,11,-21,75.1
2020-08-04 05:00:00,2020,217,4,33,11,-20,75.1
2020-08-04 06:00:00,2020,217,5,33,11,-15,75.1
2020-08-04 07:00:00,2020,217,6,13,11,-13,75.1
2020-08-04 08:00:00,2020,217,7,13,11,-12,75.1
2020-08-04 09:00:00,2020,217,8,13,11,-11,75.1
2020-08-04 10:00:00,2020,217,9,17,11,-10,75.1
2020-08-04 11:00:00,2020,217,10,17,11,-9,75.1
2020-08-04 12:00:00,2020,217,11,17,11,-5,75.1
2020-08-04 13:00:00,2020,217,12,13,11,-5,75.1
2020-08-04 14:00:00,2020,217,13,13,11,-5,75.1
2020-08-04 15:00:00,2020,217,14,13,11,-5,75.1
2020-08-04 16:00:00,2020,217,15,13,11,-2,75.1
2020-08-04 17:00:00,2020,217,16,13,11,-1,75.1
2020-08-04 18:00:00,2020,217,17,13,11,-3,75.1
2020-08-04 19:00:00,2020,217,18,13,11,-3,75.1
2020-08-04 20:00:00,2020,217,19,13,11,-6,75.1
2020-08-04 21:00:00,2020,217,20,13,11,-10,75.1
2020-08-04 22:00:00,2020,217,21,17,11,-8,75.1
2020-08-04 23:00:00,2020,217,22,17,11,-11,75.1
2020-08-05 00:00:00,2020,217,23,17,11,-13,75.1
2020-08-05 01:00:00,2020,218,0,17,12,-11,75.6
2020-08-05 02:00:00,2020,218,1,17,12,-8,75.6
2020-08-05 03:00:00,2020,218,2,17,12,-11,75.6
2020-08-05 04:00:00,2020,218,3,13,12,-12,75.6
2020-08-05 05:00:00,2020,218,4,13,12,-11,75.6
2020-08-05 06:00:00,2020,218,5,13,12,-14,75.6
2020-08-05 07:00:00,2020,218,6,10,12,-14,75.6
2020-08-05 08:00:00,2020,218,7,10,12,-12,75.6
2020-08-05 09:00:00,2020,218,8,10,12,-11,75.6
2020-08-05 10:00:00,2020,218,9,7,12,-11,75.6
2020-08-05 11:00:00,2020,218,10,7,12,-11,75.6
2020-08-05 12:00:00,2020,218,11,7,12,-9,75.6
2020-08-05 13:00:00,2020,218,12,7,12,-7,75.6
2020-08-05 14:00:00,2020,218,13,7,12,-7,75.6
2020-08-05 15:00:00,2020,218,14,7,12,-4,75.6
2020-08-05 16:00:00,2020,218,15,10,12,-2,75.6
2020-08-05 17:00:00,2020,218,16,10,12,-3,75.6
2020-08-05 18:00:00,2020,218,17,10,12,-5,75.6
2020-08-05 19:00:00,2020,218,18,23,12,-4,75.6
2020-08-05 20:00:00,2020,218,19,23,12,-7,75.6
2020-08-05 21:00:00,2020,218,20,23,12,-5,75.6
2020-08-05 22:00:00,2020,218,21,13,12,-7,75.6
2020-08-05 23:00:00,2020,218,22,13,12,-12,75.6
2020-08-06 00:00:00,2020,218,23,13,12,-15,75.6
2020-08-06 01:00:00,2020,219,0,7,14,-16,75.1
2020-08-06 02:00:00,2020,219,1,7,14,-16,75.1
2020-08-06 03:00:00,2020,219,2,7,14,-13,75.1
2020-08-06 04:00:00,2020,219,3,13,14,-7,75.1
2020-08-06 05:00:00,2020,219,4,13,14,-2,75.1
2020-08-06 06:00:00,2020,219,5,13,14,1,75.1
2020-08-06 07:00:00,2020,219,6,3,14,1,75.1
2020-08-06 08:00:00,2020,219,7,3,14,0,75.1
2020-08-06 09:00:00,2020,219,8,3,14,-2,75.1
2020-08-06 10:00:00,2020,219,9,7,14,-5,75.1
2020-08-06 11:00:00,2020,219,10,7,14,-3,75.1
2020-08-06 12:00:00,2020,219,11,7,14,-1,75.1
2020-08-06 13:00:00,2020,219,12,17,14,-3,75.1
2020-08-06 14:00:00,2020,219,13,17,14,-8,75.1
2020-08-06 15:00:00,2020,219,14,17,14,-6,75.1
2020-08-06 16:00:00,2020,219,15,13,14,-6,75.1
2020-08-06 17:00:00,2020,219,16,13,14,-8,75.1
2020-08-06 18:00:00,2020,219,17,13,14,-9,75.1
2020-08-06 19:00:00,2020,219,18,7,14,-12,75.1
2020-08-06 20:00:00,2020,219,19,7,14,-10,75.1
2020-08-06 21:00:00,2020,219,20,7,14,-4,75.1
2020-08-06 22:00:00,2020,219,21,20,14,-7,75.1
2020-08-06 23:00:00,2020,219,22,20,14,-14,75.1
2020-08-07 00:00:00,2020,219,23,20,14,-16,75.1
2020-08-07 01:00:00,2020,220,0,17,17,-13,76.0
2020-08-07 02:00:00,2020,220,1,17,17,-14,76.0
2020-08-07 03:00:00,2020,220,2,17,17,-14,76.0
2020-08-07 04:00:00,2020,220,3,10,17,-13,76.0
2020-08-07 05:00:00,2020,220,4,10,17,-13,76.0
2020-08-07 06:00:00,2020,220,5,10,17,-11,76.0
2020-08-07 07:00:00,2020,220,6,0,17,-5,76.0
2020-08-07 08:00:00,2020,220,7,0,17,-3,76.0
2020-08-07 09:00:00,2020,220,8,0,17,-2,76.0
2020-08-07 10:00:00,2020,220,9,3,17,-2,76.0
2020-08-07 11:00:00,2020,220,10,3,17,-2,76.0
2020-08-07 12:00:00,2020,220,11,3,17,2,76.0
2020-08-07 13:00:00,2020,220,12,3,17,4,76.0
2020-08-07 14:00:00,2020,220,13,3,17,5,76.0
2020-08-07 15:00:00,2020,220,14,3,17,4,76.0
2020-08-07 16:00:00,2020,220,15,3,17,3,76.0
2020-08-07 17:00:00,2020,220,16,3,17,0,76.0
2020-08-07 18:00:00,2020,220,17,3,17,0,76.0
2020-08-07 19:00:00,2020,220,18,7,17,1,76.0
2020-08-07 20:00:00,2020,220,19,7,17,1,76.0
2020-08-07 21:00:00,2020,220,20,7,17,1,76.0
2020-08-07 22:00:00,2020,220,21,13,17,-2,76.0
2020-08-07 23:00:00,2020,220,22,13,17,-3,76.0
2020-08-08 00:00:00,2020,220,23,13,17,-1,76.0
2020-08-08 01:00:00,2020,221,0,20,12,-3,76.8
2020-08-08 02:00:00,2020,221,1,20,12,-6,76.8
2020-08-08 03:00:00,2020,221,2,20,12,-5,76.8
2020-08-08 04:00:00,2020,221,3,17,12,-4,76.8
2020-08-08 05:00:00,2020,221,4,17,12,-4,76.8
2020-08-08 06:00:00,2020,221,5,17,12,-5,76.8
2020-08-08 07:00:00,2020,221,6,13,12,-8,76.8
2020-08-08 08:00:00,2020,221,7,13,12,-10,76.8
2020-08-08 09:00:00,2020,221,8,13,12,-11,76.8
2020-08-08 10:00:00,2020,221,9,10,12,-7,76.8
2020-08-08 11:00:00,2020,221,10,10,12,-5,76.8
2020-08-08 12:00:00,2020,221,11,10,12,-4,76.8
2020-08-08 13:00:00,2020,221,12,13,12,-7,76.8
2020-08-08 14:00:00,2020,221,13,13,12,-8,76.8
2020-08-08 15:00:00,2020,221,14,13,12,-8,76.8
2020-08-08 16:00:00,2020,221,15,10,12,-10,76.8
2020-08-08 17:00:00,2020,221,16,10,12,-12,76.8
2020-08-08 18:00:00,2020,221,17,10,12,-12,76.8
2020-08-08 19:00:00,2020,221,18,7,12,-12,76.8
2020-08-08 20:00:00,2020,221,19,7,12,-10,76.8
2020-08-08 21:00:00,2020,221,20,7,12,-7,76.8
2020-08-08 22:00:00,2020,221,21,3,12,-2,76.8
2020-08-08 23:00:00,2020,221,22,3,12,0,76.8
2020-08-09 00:00:00,2020,221,23,3,12,-2,76.8
2020-08-09 01:00:00,2020,222,0,0,13,-4,76.0
2020-08-09 02:00:00,2020,222,1,0,13,-7,76.0
2020-08-09 03:00:00,2020,222,2,0,13,-8,76.0
2020-08-09 04:00:00,2020,222,3,3,13,-7,76.0
2020-08-09 05:00:00,2020,222,4,3,13,-7,76.0
2020-08-09 06:00:00,2020,222,5,3,13,-5,76.0
2020-08-09 07:00:00,2020,222,6,3,13,-2,76.0
2020-08-09 08:00:00,2020,222,7,3,13,-1,76.0
2020-08-09 09:00:00,2020,222,8,3,13,-2,76.0
2020-08-09 10:00:00,2020,222,9,7,13,-7,76.0
2020-08-09 11:00:00,2020,222,10,7,13,-8,76.0
2020-08-09 12:00:00,2020,222,11,7,13,-8,76.0
2020-08-09 13:00:00,2020,222,12,3,13,-8,76.0
2020-08-09 14:00:00,2020,222,13,3,13,-8,76.0
2020-08-09 15:00:00,2020,222,14,3,13,-6,76.0
2020-08-09 16:00:00,2020,222,15,3,13,-3,76.0
2020-08-09 17:00:00,2020,222,16,3,13,-4,76.0
2020-08-09 18:00:00,2020,222,17,3,13,-5,76.0
2020-08-09 19:00:00,2020,222,18,3,13,-4,76.0
2020-08-09 20:00:00,2020,222,19,3,13,0,76.0
2020-08-09 21:00:00,2020,222,20,3,13,4,76.0
2020-08-09 22:00:00,2020,222,21,7,13,5,76.0
2020-08-09 23:00:00,2020,222,22,7,13,5,76.0
2020-08-10 00:00:00,2020,222,23,7,13,6,76.0
2020-08-10 01:00:00,2020,223,0,3,13,4,76.2
2020-08-10 02:00:00,2020,223,1,3,13,4,76.2
2020-08-10 03:00:00,2020,223,2,3,13,6,76.2
2020-08-10 04:00:00,2020,223,3,3,13,5,76.2
2020-08-10 05:00:00,2020,223,4,3,13,2,76.2
2020-08-10 06:00:00,2020,223,5,3,13,0,76.2
2020-08-10 07:00:00,2020,223,6,3,13,-3,76.2
2020-08-10 08:00:00,2020,223,7,3,13,-5,76.2
2020-08-10 09:00:00,2020,223,8,3,13,-6,76.2
2020-08-10 10:00:00,2020,223,9,3,13,-7,76.2
2020-08-10 11:00:00,2020,223,10,3,13,-5,76.2
2020-08-10 12:00:00,2020,223,11,3,13,-4,76.2
2020-08-10 13:00:00,2020,223,12,0,13,-5,76.2
2020-08-10 14:00:00,2020,223,13,0,13,-4,76.2
2020-08-10 15:00:00,2020,223,14,0,13,0,76.2
2020-08-10 16:00:00,2020,223,15,7,13,1,76.2
2020-08-10 17:00:00,2020,223,16,7,13,-1,76.2
2020-08-10 18:00:00,2020,223,17,7,13,-1,76.2
2020-08-10 19:00:00,2020,223,18,3,13,0,76.2
2020-08-10 20:00:00,2020,223,19,3,13,3,76.2
2020-08-10 21:00:00,2020,223,20,3,13,4,76.2
2020-08-10 22:00:00,2020,223,21,7,13,3,76.2
2020-08-10 23:00:00,2020,223,22,7,13,1,76.2
2020-08-11 00:00:00,2020,223,23,7,13,-1,76.2
2020-08-11 01:00:00,2020,224,0,10,12,2,75.4
2020-08-11 02:00:00,2020,224,1,10,12,1,75.4
2020-08-11 03:00:00,2020,224,2,10,12,-3,75.4
2020-08-11 04:00:00,2020,224,3,7,12,-6,75.4
2020-08-11 05:00:00,2020,224,4,7,12,-6,75.4
2020-08-11 06:00:00,2020,224,5,7,12,-5,75.4
2020-08-11 07:00:00,2020,224,6,3,12,-4,75.4
2020-08-11 08:00:00,2020,224,7,3,12,-3,75.4
2020-08-11 09:00:00,2020,224,8,3,12,-4,75.4
2020-08-11 10:00:00,2020,224,9,3,12,-3,75.4
2020-08-11 11:00:00,2020,224,10,3,12,-2,75.4
2020-08-11 12:00:00,2020,224,11,3,12,-3,75.4
2020-08-11 13:00:00,2020,224,12,3,12,-3,75.4
2020-08-11 14:00:00,2020,224,13,3,12,0,75.4
2020-08-11 15:00:00,2020,224,14,3,12,1,75.4
2020-08-11 16:00:00,2020,224,15,0,12,2,75.4
2020-08-11 17:00:00,2020,224,16,0,12,1,75.4
2020-08-11 18:00:00,2020,224,17,0,12,1,75.4
2020-08-11 19:00:00,2020,224,18,0,12,5,75.4
2020-08-11 20:00:00,2020,224,19,0,12,6,75.4
2020-08-11 21:00:00,2020,224,20,0,12,5,75.4
2020-08-11 22:00:00,2020,224,21,3,12,4,75.4
2020-08-11 23:00:00,2020,224,22,3,12,7,75.4
2020-08-12 00:00:00,2020,224,23,3,12,10,75.4
2020-08-12 01:00:00,2020,225,0,3,17,10,75.1
2020-08-12 02:00:00,2020,225,1,3,17,10,75.1
2020-08-12 03:00:00,2020,225,2,3,17,12,75.1
2020-08-12 04:00:00,2020,225,3,13,17,9,75.1
2020-08-12 05:00:00,2020,225,4,13,17,5,75.1
2020-08-12 06:00:00,2020,225,5,13,17,3,75.1
2020-08-12 07:00:00,2020,225,6,10,17,2,75.1
2020-08-12 08:00:00,2020,225,7,10,17,2,75.1
2020-08-12 09:00:00,2020,225,8,10,17,0,75.1
2020-08-12 10:00:00,2020,225,9,7,17,1,75.1
2020-08-12 11:00:00,2020,225,10,7,17,2,75.1
2020-08-12 12:00:00,2020,225,11,7,17,3,75.1
2020-08-12 13:00:00,2020,225,12,10,17,3,75.1
2020-08-12 14:00:00,2020,225,13,10,17,6,75.1
2020-08-12 15:00:00,2020,225,14,10,17,7,75.1
2020-08-12 16:00:00,2020,225,15,7,17,8,75.1
2020-08-12 17:00:00,2020,225,16,7,17,8,75.1
2020-08-12 18:00:00,2020,225,17,7,17,7,75.1
2020-08-12 19:00:00,2020,225,18,7,17,5,75.1
2020-08-12 20:00:00,2020,225,19,7,17,4,75.1
2020-08-12 21:00:00,2020,225,20,7,17,6,75.1
2020-08-12 22:00:00,2020,225,21,3,17,7,75.1
2020-08-12 23:00:00,2020,225,22,3,17,5,75.1
2020-08-13 00:00:00,2020,225,23,3,17,2,75.1
2020-08-13 01:00:00,2020,226,0,17,10,1,74.2
2020-08-13 02:00:00,2020,226,1,17,10,0,74.2
2020-08-13 03:00:00,2020,226,2,17,10,0,74.2
2020-08-13 04:00:00,2020,226,3,7,10,-2,74.2
2020-08-13 05:00:00,2020,226,4,7,10,-1,74.2
2020-08-13 06:00:00,2020,226,5,7,10,2,74.2
2020-08-13 07:00:00,2020,226,6,3,10,4,74.2
2020-08-13 08:00:00,2020,226,7,3,10,7,74.2
2020-08-13 09:00:00,2020,226,8,3,10,6,74.2
2020-08-13 10:00:00,2020,226,9,3,10,5,74.2
2020-08-13 11:00:00,2020,226,10,3,10,4,74.2
2020-08-13 12:00:00,2020,226,11,3,10,2,74.2
2020-08-13 13:00:00,2020,226,12,13,10,2,74.2
2020-08-13 14:00:00,2020,226,13,13,10,2,74.2
2020-08-13 15:00:00,2020,226,14,13,10,3,74.2
2020-08-13 16:00:00,2020,226,15,3,10,2,74.2
2020-08-13 17:00:00,2020,226,16,3,10,3,74.2
2020-08-13 18:00:00,2020,226,17,3,10,1,74.2
2020-08-13 19:00:00,2020,226,18,3,10,-1,74.2
2020-08-13 20:00:00,2020,226,19,3,10,-1,74.2
2020-08-13 21:00:00,2020,226,20,3,10,2,74.2
2020-08-13 22:00:00,2020,226,21,13,10,-1,74.2
2020-08-13 23:00:00,2020,226,22,13,10,-5,74.2
2020-08-14 00:00:00,2020,226,23,13,10,-5,74.2
2020-08-14 01:00:00,2020,227,0,10,5,-2,72.6
2020-08-14 02:00:00,2020,227,1,10,5,1,72.6
2020-08-14 03:00:00,2020,227,2,10,5,6,72.6
2020-08-14 04:00:00,2020,227,3,17,5,4,72.6
2020-08-14 05:00:00,2020,227,4,17,5,1,72.6
2020-08-14 06:00:00,2020,227,5,17,5,3,72.6
2020-08-14 07:00:00,2020,227,6,3,5,3,72.6
2020-08-14 08:00:00,2020,227,7,3,5,2,72.6
2020-08-14 09:00:00,2020,227,8,3,5,3,72.6
2020-08-14 10:00:00,2020,227,9,3,5,6,72.6
2020-08-14 11:00:00,2020,227,10,3,5,8,72.6
2020-08-14 12:00:00,2020,227,11,3,5,7,72.6
2020-08-14 13:00:00,2020,227,12,7,5,5,72.6
2020-08-14 14:00:00,2020,227,13,7,5,6,72.6
2020-08-14 15:00:00,2020,227,14,7,5,6,72.6
2020-08-14 16:00:00,2020,227,15,3,5,7,72.6
2020-08-14 17:00:00,2020,227,16,3,5,6,72.6
2020-08-14 18:00:00,2020,227,17,3,5,3,72.6
2020-08-14 19:00:00,2020,227,18,7,5,-1,72.6
2020-08-14 20:00:00,2020,227,19,7,5,-5,72.6
2020-08-14 21:00:00,2020,227,20,7,5,-8,72.6
2020-08-14 22:00:00,2020,227,21,7,5,-9,72.6
2020-08-14 23:00:00,2020,227,22,7,5,-9,72.6
2020-08-15 00:00:00,2020,227,23,7,5,-11,72.6
2020-08-15 01:00:00,2020,228,0,0,0,-10,72.4
2020-08-15 02:00:00,2020,228,1,0,0,-5,72.4
2020-09-03 22:00:00,2020,247,21,17,0,-15,71.2
2020-09-03 23:00:00,2020,247,22,17,0,-17,71.2
2020-09-04 00:00:00,2020,247,23,17,0,-21,71.2
2020-09-04 01:00:00,2020,248,0,27,0,-22,70.8
2020-09-04 02:00:00,2020,248,1,27,0,-23,70.8
2020-09-04 03:00:00,2020,248,2,27,0,-19,70.8
2020-09-04 04:00:00,2020,248,3,13,0,-16,70.8
2020-09-04 05:00:00,2020,248,4,13,0,-14,70.8
2020-09-04 06:00:00,2020,248,5,13,0,-15,70.8
2020-09-04 07:00:00,2020,248,6,13,0,-18,70.8
2020-09-04 08:00:00,2020,248,7,13,0,-18,70.8
2020-09-04 09:00:00,2020,248,8,13,0,-15,70.8
2020-09-04 10:00:00,2020,248,9,20,0,-11,70.8
2020-09-04 11:00:00,2020,248,10,20,0,-18,70.8
2020-09-04 12:00:00,2020,248,11,20,0,-19,70.8
2020-09-04 13:00:00,2020,248,12,20,0,-18,70.8
2020-09-04 14:00:00,2020,248,13,20,0,-22,70.8
2020-09-04 15:00:00,2020,248,14,20,0,-21,70.8
2020-09-04 16:00:00,2020,248,15,17,0,-26,70.8
2020-09-04 17:00:00,2020,248,16,17,0,-27,70.8
2020-09-04 18:00:00,2020,248,17,17,0,-25,70.8
2020-09-04 19:00:00,2020,248,18,23,0,-22,70.8
2020-09-04 20:00:00,2020,248,19,23,0,-20,70.8
2020-09-04 21:00:00,2020,248,20,23,0,-24,70.8
2020-09-04 22:00:00,2020,248,21,3,0,-22,70.8
2020-09-04 23:00:00,2020,248,22,3,0,-21,70.8
2020-09-05 00:00:00,2020,248,23,3,0,-21,70.8
2020-09-05 01:00:00,2020,249,0,17,0,-21,70.3
2020-09-05 02:00:00,2020,249,1,17,0,-22,70.3
2020-09-05 03:00:00,2020,249,2,17,0,-23,70.3
2020-09-05 04:00:00,2020,249,3,13,0,-22,70.3
2020-09-05 05:00:00,2020,249,4,13,0,-19,70.3
2020-09-05 06:00:00,2020,249,5,13,0,-16,70.3
2020-09-05 07:00:00,2020,249,6,17,0,-15,70.3
2020-09-05 08:00:00,2020,249,7,17,0,-15,70.3
2020-09-05 09:00:00,2020,249,8,17,0,-21,70.3
2020-09-05 10:00:00,2020,249,9,20,0,-23,70.3
2020-09-05 11:00:00,2020,249,10,20,0,-22,70.3
2020-09-05 12:00:00,2020,249,11,20,0,-11,70.3
2020-09-05 13:00:00,2020,249,12,17,0,-7,70.3
2020-09-05 14:00:00,2020,249,13,17,0,-7,70.3
2020-09-05 15:00:00,2020,249,14,17,0,-7,70.3
2020-09-05 16:00:00,2020,249,15,3,0,-8,70.3
2020-09-05 17:00:00,2020,249,16,3,0,-9,70.3
2020-09-05 18:00:00,2020,249,17,3,0,-7,70.3
2020-09-05 19:00:00,2020,249,18,10,0,-8,70.3
2020-09-05 20:00:00,2020,249,19,10,0,-6,70.3
2020-09-05 21:00:00,2020,249,20,10,0,-6,70.3
2020-09-05 22:00:00,2020,249,21,10,0,-8,70.3
2020-09-05 23:00:00,2020,249,22,10,0,-9,70.3
2020-09-06 00:00:00,2020,249,23,10,0,-14,70.3
2020-09-06 01:00:00,2020,250,0,20,0,-18,70.5
2020-09-06 02:00:00,2020,250,1,20,0,-21,70.5
2020-09-06 03:00:00,2020,250,2,20,0,-16,70.5
2020-09-06 04:00:00,2020,250,3,10,0,-12,70.5
2020-09-06 05:00:00,2020,250,4,10,0,-10,70.5
2020-09-06 06:00:00,2020,250,5,10,0,-11,70.5
2020-09-06 07:00:00,2020,250,6,3,0,-8,70.5
2020-09-06 08:00:00,2020,250,7,3,0,-5,70.5
2020-09-06 09:00:00,2020,250,8,3,0,-7,70.5
2020-09-06 10:00:00,2020,250,9,10,0,-6,70.5
2020-09-06 11:00:00,2020,250,10,10,0,-6,70.5
2020-09-06 12:00:00,2020,250,11,10,0,-9,70.5
2020-09-06 13:00:00,2020,250,12,10,0,-9,70.5
2020-09-06 14:00:00,2020,250,13,10,0,-7,70.5
2020-09-06 15:00:00,2020,250,14,10,0,-6,70.5
2020-09-06 16:00:00,2020,250,15,3,0,-7,70.5
2020-09-06 17:00:00,2020,250,16,3,0,-7,70.5
2020-09-06 18:00:00,2020,250,17,3,0,-6,70.5
2020-09-06 19:00:00,2020,250,18,7,0,-5,70.5
2020-09-06 20:00:00,2020,250,19,7,0,-6,70.5
2020-09-06 21:00:00,2020,250,20,7,0,-9,70.5
2020-09-06 22:00:00,2020,250,21,17,0,-15,70.5
2020-09-06 23:00:00,2020,250,22,17,0,-20,70.5
2020-09-07 00:00:00,2020,250,23,17,0,-21,70.5
2020-09-07 01:00:00,2020,251,0,10,0,-21,71.3
2020-09-07 02:00:00,2020,251,1,10,0,-16,71.3
2020-09-07 03:00:00,2020,251,2,10,0,-13,71.3
2020-09-07 04:00:00,2020,251,3,13,0,-11,71.3
2020-09-07 05:00:00,2020,251,4,13,0,-14,71.3
2020-09-07 06:00:00,2020,251,5,13,0,-17,71.3
2020-09-07 07:00:00,2020,251,6,13,0,-14,71.3
2020-09-07 08:00:00,2020,251,7,13,0,-10,71.3
2020-09-07 09:00:00,2020,251,8,13,0,-11,71.3
2020-09-07 10:00:00,2020,251,9,7,0,-11,71.3
2020-09-07 11:00:00,2020,251,10,7,0,-13,71.3
2020-09-07 12:00:00,2020,251,11,7,0,-14,71.3
2020-09-07 13:00:00,2020,251,12,7,0,-15,71.3
2020-09-07 14:00:00,2020,251,13,7,0,-12,71.3
2020-09-07 15:00:00,2020,251,14,7,0,-12,71.3
2020-09-07 16:00:00,2020,251,15,10,0,-10,71.3
2020-09-07 17:00:00,2020,251,16,10,0,-13,71.3
2020-09-07 18:00:00,2020,251,17,10,0,-12,71.3
2020-09-07 19:00:00,2020,251,18,3,0,-9,71.3
2020-09-07 20:00:00,2020,251,19,3,0,-8,71.3
2020-09-07 21:00:00,2020,251,20,3,0,-10,71.3
2020-09-07 22:00:00,2020,251,21,0,0,-14,71.3
2020-09-07 23:00:00,2020,251,22,0,0,-16,71.3
2020-09-08 00:00:00,2020,251,23,0,0,-16,71.3
2020-09-08 01:00:00,2020,252,0,7,0,-12,70.9
2020-09-08 02:00:00,2020,252,1,7,0,-12,70.9
2020-09-08 03:00:00,2020,252,2,7,0,-13,70.9
2020-09-08 04:00:00,2020,252,3,3,0,-12,70.9
2020-09-08 05:00:00,2020,252,4,3,0,-12,70.9
2020-09-08 06:00:00,2020,252,5,3,0,-12,70.9
2020-09-08 07:00:00,2020,252,6,10,0,-9,70.9
2020-09-08 08:00:00,2020,252,7,10,0,-6,70.9
2020-09-08 09:00:00,2020,252,8,10,0,-6,70.9
2020-09-08 10:00:00,2020,252,9,10,0,-1,70.9
2020-09-08 11:00:00,2020,252,10,10,0,2,70.9
2020-09-08 12:00:00,2020,252,11,10,0,1,70.9
2020-09-08 13:00:00,2020,252,12,7,0,2,70.9
2020-09-08 14:00:00,2020,252,13,7,0,3,70.9
2020-09-08 15:00:00,2020,252,14,7,0,-1,70.9
2020-09-08 16:00:00,2020,252,15,13,0,-6,70.9
2020-09-08 17:00:00,2020,252,16,13,0,-7,70.9
2020-09-08 18:00:00,2020,252,17,13,0,-9,70.9
2020-09-08 19:00:00,2020,252,18,10,0,-7,70.9
2020-09-08 20:00:00,2020,252,19,10,0,-5,70.9
2020-09-08 21:00:00,2020,252,20,10,0,-3,70.9
2020-09-08 22:00:00,2020,252,21,0,0,-2,70.9
2020-09-08 23:00:00,2020,252,22,0,0,-2,70.9
2020-09-09 00:00:00,2020,252,23,0,0,-2,70.9
2020-09-09 01:00:00,2020,253,0,7,0,-3,70.7
2020-09-09 02:00:00,2020,253,1,7,0,-4,70.7
2020-09-09 03:00:00,2020,253,2,7,0,-4,70.7
2020-09-09 04:00:00,2020,253,3,0,0,-5,70.7
2020-09-09 05:00:00,2020,253,4,0,0,-5,70.7
2020-09-09 06:00:00,2020,253,5,0,0,-6,70.7
2020-09-09 07:00:00,2020,253,6,0,0,-2,70.7
2020-09-09 08:00:00,2020,253,7,0,0,0,70.7
2020-09-09 09:00:00,2020,253,8,0,0,0,70.7
2020-09-09 10:00:00,2020,253,9,0,0,1,70.7
2020-09-09 11:00:00,2020,253,10,0,0,2,70.7
2020-09-09 12:00:00,2020,253,11,0,0,1,70.7
2020-09-09 13:00:00,2020,253,12,0,0,1,70.7
2020-09-09 14:00:00,2020,253,13,0,0,0,70.7
2020-09-09 15:00:00,2020,253,14,0,0,-1,70.7
2020-09-09 16:00:00,2020,253,15,3,0,-2,70.7
2020-09-09 17:00:00,2020,253,16,3,0,-1,70.7
2020-09-09 18:00:00,2020,253,17,3,0,0,70.7
2020-09-09 19:00:00,2020,253,18,0,0,0,70.7
2020-09-09 20:00:00,2020,253,19,0,0,1,70.7
2020-09-09 21:00:00,2020,253,20,0,0,0,70.7
2020-09-09 22:00:00,2020,253,21,0,0,-1,70.7
2020-09-09 23:00:00,2020,253,22,0,0,1,70.7
2020-09-10 00:00:00,2020,253,23,0,0,1,70.7
2020-09-10 01:00:00,2020,254,0,0,0,0,70.2
2020-09-10 02:00:00,2020,254,1,0,0,0,70.2
2020-09-10 03:00:00,2020,254,2,0,0,0,70.2
2020-09-10 04:00:00,2020,254,3,0,0,-1,70.2
2020-09-10 05:00:00,2020,254,4,0,0,-1,70.2
2020-09-10 06:00:00,2020,254,5,0,0,-2,70.2
2020-09-10 07:00:00,2020,254,6,0,0,-3,70.2
2020-09-10 08:00:00,2020,254,7,0,0,-1,70.2
2020-09-10 09:00:00,2020,254,8,0,0,1,70.2
2020-09-10 10:00:00,2020,254,9,3,0,3,70.2
2020-09-10 11:00:00,2020,254,10,3,0,-1,70.2
2020-09-10 12:00:00,2020,254,11,3,0,1,70.2
2020-09-10 13:00:00,2020,254,12,3,0,2,70.2
2020-09-10 14:00:00,2020,254,13,3,0,4,70.2
2020-09-10 15:00:00,2020,254,14,3,0,3,70.2
2020-09-10 16:00:00,2020,254,15,3,0,2,70.2
2020-09-10 17:00:00,2020,254,16,3,0,2,70.2
2020-09-10 18:00:00,2020,254,17,3,0,4,70.2
2020-09-10 19:00:00,2020,254,18,10,0,3,70.2
2020-09-10 20:00:00,2020,254,19,10,0,1,70.2
2020-09-10 21:00:00,2020,254,20,10,0,1,70.2
2020-09-10 22:00:00,2020,254,21,3,0,4,70.2
2020-09-10 23:00:00,2020,254,22,3,0,4,70.2
2020-09-11 00:00:00,2020,254,23,3,0,2,70.2
2020-09-11 01:00:00,2020,255,0,0,0,2,69.6
2020-09-11 02:00:00,2020,255,1,0,0,4,69.6
2020-09-11 03:00:00,2020,255,2,0,0,3,69.6
2020-09-11 04:00:00,2020,255,3,0,0,4,69.6
2020-09-11 05:00:00,2020,255,4,0,0,2,69.6
2020-09-11 06:00:00,2020,255,5,0,0,2,69.6
2020-09-11 07:00:00,2020,255,6,3,0,2,69.6
2020-09-11 08:00:00,2020,255,7,3,0,2,69.6
2020-09-11 09:00:00,2020,255,8,3,0,-1,69.6
2020-09-11 10:00:00,2020,255,9,3,0,-2,69.6
2020-09-11 11:00:00,2020,255,10,3,0,-1,69.6
2020-09-11 12:00:00,2020,255,11,3,0,-2,69.6
2020-09-11 13:00:00,2020,255,12,0,0,-2,69.6
2020-09-11 14:00:00,2020,255,13,0,0,-1,69.6
2020-09-11 15:00:00,2020,255,14,0,0,-1,69.6
2020-09-11 16:00:00,2020,255,15,7,0,-1,69.6
2020-09-11 17:00:00,2020,255,16,7,0,0,69.6
2020-09-11 18:00:00,2020,255,17,7,0,-2,69.6
2020-09-11 19:00:00,2020,255,18,10,0,0,69.6
2020-09-11 20:00:00,2020,255,19,10,0,-1,69.6
2020-09-11 21:00:00,2020,255,20,10,0,-2,69.6
2020-09-11 22:00:00,2020,255,21,10,0,-6,69.6
2020-09-11 23:00:00,2020,255,22,10,0,-10,69.6
2020-09-12 00:00:00,2020,255,23,10,0,-11,69.6
2020-09-12 01:00:00,2020,256,0,13,0,-10,70.2
2020-09-12 02:00:00,2020,256,1,13,0,-8,70.2
2020-09-12 03:00:00,2020,256,2,13,0,-7,70.2
2020-09-12 04:00:00,2020,256,3,13,0,-5,70.2
2020-09-12 05:00:00,2020,256,4,13,0,-5,70.2
2020-09-12 06:00:00,2020,256,5,13,0,-8,70.2
2020-09-12 07:00:00,2020,256,6,20,0,-8,70.2
2020-09-12 08:00:00,2020,256,7,20,0,-7,70.2
2020-09-12 09:00:00,2020,256,8,20,0,-8,70.2
2020-09-12 10:00:00,2020,256,9,13,0,-8,70.2
2020-09-12 11:00:00,2020,256,10,13,0,-2,70.2
2020-09-12 12:00:00,2020,256,11,13,0,1,70.2
2020-09-12 13:00:00,2020,256,12,3,0,1,70.2
2020-09-12 14:00:00,2020,256,13,3,0,1,70.2
2020-09-12 15:00:00,2020,256,14,3,0,-2,70.2
2020-09-12 16:00:00,2020,256,15,7,0,-5,70.2
2020-09-12 17:00:00,2020,256,16,7,0,-4,70.2
2020-09-12 18:00:00,2020,256,17,7,0,-2,70.2
2020-09-12 19:00:00,2020,256,18,13,0,0,70.2
2020-09-12 20:00:00,2020,256,19,13,0,-1,70.2
2020-09-12 21:00:00,2020,256,20,13,0,-3,70.2
2020-09-12 22:00:00,2020,256,21,10,0,-5,70.2
2020-09-12 23:00:00,2020,256,22,10,0,-8,70.2
2020-09-13 00:00:00,2020,256,23,10,0,-9,70.2
2020-09-13 01:00:00,2020,257,0,10,0,-7,70.6
2020-09-13 02:00:00,2020,257,1,10,0,-8,70.6
2020-09-13 03:00:00,2020,257,2,10,0,-11,70.6
2020-09-13 04:00:00,2020,257,3,13,0,-11,70.6
2020-09-13 05:00:00,2020,257,4,13,0,-6,70.6
2020-09-13 06:00:00,2020,257,5,13,0,-5,70.6
2020-09-13 07:00:00,2020,257,6,13,0,-6,70.6
2020-09-13 08:00:00,2020,257,7,13,0,-9,70.6
2020-09-13 09:00:00,2020,257,8,13,0,-8,70.6
2020-09-13 10:00:00,2020,257,9,3,0,-6,70.6
2020-09-13 11:00:00,2020,257,10,3,0,-3,70.6
2020-09-13 12:00:00,2020,257,11,3,0,-2,70.6
2020-09-13 13:00:00,2020,257,12,13,0,0,70.6
2020-09-13 14:00:00,2020,257,13,13,0,2,70.6
2020-09-13 15:00:00,2020,257,14,13,0,0,70.6
2020-09-13 16:00:00,2020,257,15,17,0,1,70.6
2020-09-13 17:00:00,2020,257,16,17,0,1,70.6
2020-09-13 18:00:00,2020,257,17,17,0,9,70.6
2020-09-13 19:00:00,2020,257,18,13,0,8,70.6
2020-09-13 20:00:00,2020,257,19,13,0,8,70.6
2020-09-13 21:00:00,2020,257,20,13,0,12,70.6
2020-09-13 22:00:00,2020,257,21,30,0,8,70.6
2020-09-13 23:00:00,2020,257,22,30,0,8,70.6
2020-09-14 00:00:00,2020,257,23,30,0,9,70.6
2020-09-14 01:00:00,2020,258,0,33,2,4,69.7
2020-09-14 02:00:00,2020,258,1,33,2,-10,69.7
2020-09-14 03:00:00,2020,258,2,33,2,-19,69.7
2020-09-14 04:00:00,2020,258,3,33,2,-24,69.7
2020-09-14 05:00:00,2020,258,4,33,2,-35,69.7
2020-09-14 06:00:00,2020,258,5,33,2,-34,69.7
2020-09-14 07:00:00,2020,258,6,23,2,-29,69.7
2020-09-14 08:00:00,2020,258,7,23,2,-26,69.7
2020-09-14 09:00:00,2020,258,8,23,2,-29,69.7
2020-09-14 10:00:00,2020,258,9,27,2,-15,69.7
2020-09-14 11:00:00,2020,258,10,27,2,-10,69.7
2020-09-14 12:00:00,2020,258,11,27,2,-6,69.7
2020-09-14 13:00:00,2020,258,12,30,2,-12,69.7
2020-09-14 14:00:00,2020,258,13,30,2,-13,69.7
2020-09-14 15:00:00,2020,258,14,30,2,-10,69.7
2020-09-14 16:00:00,2020,258,15,10,2,-9,69.7
2020-09-14 17:00:00,2020,258,16,10,2,-8,69.7
2020-09-14 18:00:00,2020,258,17,10,2,-6,69.7
2020-09-14 19:00:00,2020,258,18,7,2,-7,69.7
2020-09-14 20:00:00,2020,258,19,7,2,-8,69.7
2020-09-14 21:00:00,2020,258,20,7,2,-10,69.7
2020-09-14 22:00:00,2020,258,21,20,2,-12,69.7
2020-09-14 23:00:00,2020,258,22,20,2,-14,69.7
2020-09-15 00:00:00,2020,258,23,20,2,-17,69.7
2020-09-15 01:00:00,2020,259,0,23,0,-17,69.6
2020-09-15 02:00:00,2020,259,1,23,0,-18,69.6
2020-09-15 03:00:00,2020,259,2,23,0,-16,69.6
2020-09-15 04:00:00,2020,259,3,20,0,-17,69.6
2020-09-15 05:00:00,2020,259,4,20,0,-20,69.6
2020-09-15 06:00:00,2020,259,5,20,0,-18,69.6
2020-09-15 07:00:00,2020,259,6,13,0,-19,69.6
2020-09-15 08:00:00,2020,259,7,13,0,-16,69.6
2020-09-15 09:00:00,2020,259,8,13,0,-20,69.6
2020-09-15 10:00:00,2020,259,9,13,0,-23,69.6
2020-09-15 11:00:00,2020,259,10,13,0,-26,69.6
2020-09-15 12:00:00,2020,259,11,13,0,-23,69.6
2020-09-15 13:00:00,2020,259,12,3,0,-16,69.6
2020-09-15 14:00:00,2020,259,13,3,0,-13,69.6
2020-09-15 15:00:00,2020,259,14,3,0,-14,69.6
2020-09-15 16:00:00,2020,259,15,7,0,-15,69.6
2020-09-15 17:00:00,2020,259,16,7,0,-15,69.6
2020-09-15 18:00:00,2020,259,17,7,0,-13,69.6
2020-09-15 19:00:00,2020,259,18,13,0,-11,69.6
2020-09-15 20:00:00,2020,259,19,13,0,-9,69.6
2020-09-15 21:00:00,2020,259,20,13,0,-9,69.6
2020-09-15 22:00:00,2020,259,21,13,0,-12,69.6
2020-09-15 23:00:00,2020,259,22,13,0,-15,69.6
2020-09-16 00:00:00,2020,259,23,13,0,-17,69.6
2020-09-16 01:00:00,2020,260,0,0,0,-15,70.2
2020-09-16 02:00:00,2020,260,1,0,0,-12,70.2
2020-09-16 03:00:00,2020,260,2,0,0,-12,70.2
2020-09-16 04:00:00,2020,260,3,3,0,-13,70.2
2020-09-16 05:00:00,2020,260,4,3,0,-11,70.2
2020-09-16 06:00:00,2020,260,5,3,0,-9,70.2
2020-09-16 07:00:00,2020,260,6,10,0,-6,70.2
2020-09-16 08:00:00,2020,260,7,10,0,-7,70.2
2020-09-16 09:00:00,2020,260,8,10,0,-6,70.2
2020-09-16 10:00:00,2020,260,9,10,0,-4,70.2
2020-09-16 11:00:00,2020,260,10,10,0,0,70.2
2020-09-16 12:00:00,2020,260,11,10,0,3,70.2
2020-09-16 13:00:00,2020,260,12,0,0,4,70.2
2020-09-16 14:00:00,2020,260,13,0,0,2,70.2
2020-09-16 15:00:00,2020,260,14,0,0,0,70.2
2020-09-16 16:00:00,2020,260,15,10,0,-2,70.2
2020-09-16 17:00:00,2020,260,16,10,0,-4,70.2
2020-09-16 18:00:00,2020,260,17,10,0,-4,70.2
2020-09-16 19:00:00,2020,260,18,10,0,-4,70.2
2020-09-16 20:00:00,2020,260,19,10,0,-4,70.2
2020-09-16 21:00:00,2020,260,20,10,0,-6,70.2
2020-09-16 22:00:00,2020,260,21,3,0,-13,70.2
2020-09-16 23:00:00,2020,260,22,3,0,-17,70.2
2020-09-17 00:00:00,2020,260,23,3,0,-15,70.2
python numpy matplotlib time-series seaborn
2个回答
3
投票

下面是您询问的各种方法的示例(包括感兴趣的 3D 图)。

imshow

pcolormesh

contourf

plot_surface
(包括轮廓投影):


import pandas as pd
from matplotlib import pyplot as plt, dates as mdates
import numpy as np

#
#Load and format data
#
df = pd.read_csv('spaceWeather.csv')[1:]
df = df.rename(columns={'Unnamed: 0': 'date'})
df.date = pd.to_datetime(df.date)
df = df.sort_values(by='date')

df = df.drop(columns=['year', 'doy', 'hr']) #remove some columns
df['day_of_year'] = df['date'].dt.day_of_year #new columns
df['hour'] = df['date'].dt.hour

df['event'] = ''
df.loc[(df.kp > 40) | (df.dst < -30), 'event'] = 'S'
df.loc[df.date == pd.Timestamp('2020/09/01 01:00'), 'event'] = 'E'

img_data = df.pivot_table(index='hour', columns='day_of_year', values='dst').values
labels = df.pivot(index='hour', columns='day_of_year', values='event').values
dates = pd.date_range(
    start=df.date.min(),
    end=df.date.max() + pd.offsets.Day(),
    freq='D', inclusive='both'
)

#
#Plot
#

#Select a plot type
plot_type = 'imshow'
plot_type = 'contourf'
plot_type = 'plot_surface'
plot_type = 'pcolormesh'

f, ax = plt.subplots(figsize=(11, 3))

common_params = dict(vmin=-40, vmax=20, cmap='jet_r')

if plot_type != 'imshow':
    #Everything here apart from imshow uses pre-defined regular grids X, Y
    X, Y = np.meshgrid(mdates.date2num(dates), range(img_data.shape[0]))

if plot_type == 'imshow':
    im = ax.imshow(
        img_data,
        interpolation='none',
        aspect='auto',
        origin='lower',
        extent=[
            dates[0] - pd.offsets.Hour(12),
            dates[-1] + pd.offsets.Hour(12),
            df['hour'].min(),
            df['hour'].max()
        ],
        **common_params
    )
elif plot_type == 'pcolormesh':
    im = ax.pcolormesh(X, Y, img_data, **common_params)
elif plot_type == 'contourf':
    im = ax.contourf(X, Y, img_data, levels=10, **common_params)
elif plot_type == 'plot_surface':    
    f = plt.figure(figsize=(11, 11))
    ax = f.add_subplot(projection='3d', proj_type='persp', focal_length=0.2)
    
    ax.view_init(azim=79, elev=25)
    ax.set_box_aspect(aspect=(3, 2, 1.5), zoom=0.95)

    im = ax.plot_surface(X, Y, img_data, **common_params)
    ax.contourf(X, Y, img_data, levels=10, zdir='z', offset=-35, alpha=0.3, **common_params)
    ax.contour(X, Y, img_data, levels=8, zdir='z', offset=24, alpha=0.5, linewidths=3, **common_params)
    ax.set_zlabel('Dst')

#Add labels
for (row, col), label in np.ndenumerate(labels):
    if plot_type == 'plot_surface': break #skip labels on 3d plot for simplicity
    
    if type(label) is not str: continue
    ax.text(dates[col] - pd.offsets.Hour(6), row, label, fontsize=9, fontweight='bold')

#Format x axis with dates:
ax.set_xticks(dates)
ax.xaxis.set_major_formatter(mdates.DateFormatter(fmt='%b %d'))
ax.tick_params(axis='x', rotation=90)

#Format y axis
ax.set_yticks([0, 6, 12, 18, 23])
ax.set_ylabel('UT')

#Add colorbar
aspect, fraction = (10, 0.15) if plot_type != 'plot_surface' else (5, 0.05)
f.colorbar(im, aspect=aspect, fraction=fraction, pad=0.01, label='nT')

#Title
ax.set_title(f'Dst\n(plot type: {plot_type})', fontweight='bold')

2
投票

Python 脚本执行以下操作:

  1. 导入必要的库:pandas、seaborn 和 matplotlib。

  2. 从指定路径读取名为

    spaceWeather.csv
    的 CSV 文件,跳过几列的第一行。

  3. 通过从“未命名:0”列中提取日期和时间,在数据框中创建新列“日期”和“小时”。

  4. 向数据框中添加新列“天气”。如果“kp”值大于 40 或“dst”值小于 -30,则“天气”被标记为“风暴”。否则,它仍然是一个空字符串。

  5. 删除日期为“2020-09-17”的行,因为它只有一个观察结果。

  6. 创建两个数据透视表:一个用于“天气”注释,另一个用于“夏令时”值,两者均按“日期”和“小时”索引。

    • 要切换热图的轴,您可以在
      index
      函数中互换传递给
      columns
      pivot
      的列名称,以用于
      annot
      dst
  7. 使用seaborn绘制热图,表示“dst”值。 “天气”注释用作热图上的标签。

  8. 使用

    plt.text
    在由
    x
    y
    指定的位置对图形进行注释。

  9. 将绘图保存为名为“spaceWeather.png”的 PNG 文件,然后显示它。

  • 使用Python 3.12.0、Pandas 2.2.1、Seaborn 0.13.2、Matplotlib 3.8.1实现
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# There's an issue with the first row of several columns, so they're being skipped
df = pd.read_csv('spaceWeather.csv', parse_dates=[0], usecols=[0, 4, 6])

# Create a date column
df['Date'] = df['Unnamed: 0'].dt.date

# Create an hour column
df['Hour'] = df['Unnamed: 0'].dt.hour

# Add a column labeled Weather based on the value of kp and dst
# If kp is greater than 40 or dst is less than -30, the weather is a storm, otherwise the label is ''
df['Weather'] = ''
df.loc[(df['kp'] > 40) | (df['dst'] < -30), 'Weather'] = 'Storm'

# There's only one observation for 2020-09-17, so we'll drop it
df = df[df['Date'] != pd.Timestamp('2020-09-17').date()]

# Create a pivot table for the annotations in the 'Weather' column
annot = df.pivot(index='Date', columns='Hour', values='Weather')

# Create a pivot table for the dst values
dst = df.pivot(index='Date', columns='Hour', values='dst')

# Plot the seaborn heatmap for dst, with annot for annotations
plt.figure(figsize=(16, 10))
ax = sns.heatmap(data=dst, annot=annot, fmt='', cmap='coolwarm', cbar_kws={'label': 'dst'})
ax.set_title('Space Weather')

# On 2020-09-01 add a single annotation near the date, with "Earthquake"
plt.text(0.07, 0.335, 'Earthquake', horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, fontsize=15)

plt.savefig('spaceWeather.png')
plt.show()

© www.soinside.com 2019 - 2024. All rights reserved.