Matplotlib ignoring timezone

前端 未结 2 1447
北恋
北恋 2021-02-09 13:04

The following plot

import matplotlib
f= plt.figure(figsize=(12,4))
ax = f.add_subplot(111)
df.set_index(\'timestamp\')[\'values\'].plot(ax=ax)
ax.xaxis.set_majo         


        
2条回答
  •  一个人的身影
    2021-02-09 13:55

    If you don't want to change rcParams (which seems to be an easy fix), then you can pass the timezone to mdates.DateFormatter.

    from dateutil import tz
    mdates.DateFormatter('%H:%M', tz=tz.gettz('Europe/Berlin'))
    

    The problem is that mdates.DateFormatter completely ignores everything you set in like plot_date or xaxis_date or whatever you use.

提交回复
热议问题