小编fra*_*ort的帖子

热图海报中的日期轴

一点信息:我对编程很新,这只是我第一个脚本的一小部分.这个特定部分的目标是显示一个seaborn热图,其中y轴为垂直深度,x轴为时间,科学测量强度为热函数.

如果在其他地方得到回答,我想道歉,但我的搜索能力一定让我失望.

sns.set()
nametag = 'Well_4_all_depths_capf'
Dp = D[D.well == 'well4']
print(Dp.date)


heat = Dp.pivot("depth",  "date", "capf")
### depth, date and capf are all columns of a pandas dataframe 

plt.title(nametag)

sns.heatmap(heat,  linewidths=.25)

plt.savefig('%s%s.png' % (pathheatcapf, nametag), dpi = 600)
Run Code Online (Sandbox Code Playgroud)

这是从'print(Dp.date)打印的内容所以我非常确定数据框的格式是我想要的格式,特别是年,日,月.

0    2016-08-09
1    2016-08-09
2    2016-08-09
3    2016-08-09
4    2016-08-09
5    2016-08-09
6    2016-08-09
         ...    
Run Code Online (Sandbox Code Playgroud)

但是,当我运行它时,日期轴始终打印出我不想要的空白时间(00:00等).有没有办法从日期轴中删除它们?

是否在上面的单元格中使用此函数扫描文件名并使用日期??? 使用datetime而不仅仅是日期函数是错误的吗?

D['date']=pd.to_datetime(['%s-%s-%s' %(f[0:4],f[4:6],f[6:8]) for f in             
D['filename']])
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python matplotlib python-3.x seaborn

5
推荐指数
1
解决办法
5508
查看次数

标签 统计

matplotlib ×1

python ×1

python-3.x ×1

seaborn ×1