我有一幅图,显示了一年中每一天每小时的温度
这是我写的代码:
mydateparser = lambda x: datetime.strptime(x, "%Y-%m-%d")
df = pd.read_csv("Vaderdata.csv",
usecols=['Date','Time','Temp'],
parse_dates=['Date'],
date_parser=mydateparser)
pivot = pd.pivot_table(df, values='Temp',columns='Date',index='Time')
fig, ax = plt.subplots(figsize = (12,6))
clr = sns.color_palette("coolwarm", as_cmap=True)
fig = sns.heatmap(pivot, center = 0,cmap = clr )
plt.show()
正如你所看到的,x轴不是很具有描述性。 我希望每个月都有一个带标签的大刻度,每个星期都有一个小刻度。 我发现了一些将日期时间格式化为字符串的示例,这样x轴至少可以显示一些东西,而不仅仅是零,但我还没有找到如何执行我刚才描述的操作
月份显示由MonthLocator设置为带有月份缩写的一个月。几周来,我们在DayLocator中有7天的间隔数据,并设置原始标签。使用
ax.xaxis.set_minor_formatter('%U')
本来很容易,但是相关问题 更多 >
编程相关推荐