python - How to create a unstacked bar plot with dates in X axis?
问题描述
I'm trying to create an unstacked bar plot.
I had a lot of problems to extract the dates from the data frame to be able using the with major_locator, DayLocator, etc.
Important: Date start type is datetime64[ns]
I tried many options to unstack the bars but I wasn't able to fix it.
fig, ax = plt.subplots(1,1, figsize=(15,8))
fig.suptitle('ICP: Time standing', fontsize=25, fontweight='bold')
date_listdate_list = df[df['Container'] == 1]['Date start'].tolist()
ax.bar(date_list,df[df['Container'] == 1]['Aluminum (Al)\nppb'],width = 0.1)
ax.bar(date_list,df[df['Container'] == 1]['Barium (Ba)\nppb'],width = 0.1)
myFmtx = DateFormatter("%d/%m")
ax.xaxis.set_major_locator(mdates.DayLocator(interval=1))
ax.xaxis.set_major_formatter(myFmtx)
fig.autofmt_xdate()
解决方案
推荐阅读
- python - 如何从大文件名数组中测试文件是否存在,如果文件名不以一致的方式存在,如何从数组中删除文件名?
- python - 无法将数据框转换为 stata 格式
- javascript - javascript 验证 lang, lat 为 dmc 格式
- qt - QApplication 从分段错误中恢复
- php - 如何获取artifactsrequests 表的ID,而不是我加入的表的ID
- python - 如何找到一维数组/向量的自相关矩阵
- linux - 安装后正在替换 linux 中的 npm install 文件夹
- c - 在小结构的末尾而不是在 2 个成员之间进行对齐填充会更好吗?
- html - 更改引导卡标题的颜色
- javascript - 如何在Vue中使模态可打印?