1
timedelta 인덱스로 팬더 데이터 프레임의 일부 데이터를 플롯하려고하고 있으며 내 x 축에서 타임 틱과 라벨을 사용자 정의하고 싶습니다. 이것은 간단해야하지만 힘든 일임을 입증합니다.timedelta 인덱스로 팬더 데이터 프레임에서 플로팅
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as dates
## I have a df similar to this
timestamps = pd.date_range(start="2017-05-08", freq="10T", periods=6*6)
timedeltas = timestamps - pd.to_datetime("2017-05-08")
yy = np.random.random((len(timedeltas),10))
df = pd.DataFrame(data=yy, index=timedeltas) # Ok, this is what I have
## Now I want to plot this but I want detailed control of the plot so I use matplotlib instead of df.plot
fig,axes=plt.subplots()
axes.plot(df.index.values, df.values)
#axes.plot_date(df.index, df.values, '-')
axes.xaxis.set_major_locator(dates.HourLocator(byhour=range(0,24,2)))
axes.xaxis.set_minor_locator(dates.MinuteLocator(byminute=range(0,24*60,10)))
axes.xaxis.set_major_formatter(dates.DateFormatter('%H:%M'))
plt.show()
보시다시피 진드기는 나타나지 않습니다. 예를 들어, 2 시간마다 큰 틱과 레이블을 추가하고 10 분마다 작은 틱을 추가 할 수 있습니까?
감사합니다. 어쩌면 당신은 이것도 보길 원할 것입니다 : https://stackoverflow.com/questions/43859823/heatmap-in-which-one-of-the-axis-is-of-timedelta-type – Bella