私は、このファイルhttps://drive.google.com/open?id=0B4KXs5bh3CmPWXJkQWhkbzI0WEEpython pandasでmatplotlibを使って2つのグラフをプロットするにはどうすればいいですか?
#count weekdays 0 to 4
mUserType = np.where(rides['starttime'].dt.dayofweek <= 5, 'Weekend',
'Weekday')
#count hours
mWeekHours = rides['starttime'].dt.hour
#create group by usertype
WeekdayWorkdayResult = rides.groupby([mUserType, mWeekHours,
'usertype']).size().unstack()
WeekdayWorkdayResult
このコードは、私はどのようにすることができます。この形式でmatplotlibのを使用してグラフをプロットしたいユーザタイプ、すなわち顧客や加入者
によると、週末や平日の時間をカウントするデータを持っています私? Weekday and Weekend Graph
時間とユーザータイプによる乗車回数を示します。 Workdaysの1つのプロット、週末の2つ目のプロット。ここではすべての時間ごとの乗り物のためのプロットライン
# count trips by date and by hour
ind = pd.DatetimeIndex(rides.starttime)
rides['date'] = ind.date.astype('datetime64')
rides['hour'] = ind.hour
by_hour = rides.pivot_table('tripduration', aggfunc='count',
index=['date', 'hour'],
columns='usertype').fillna(0).reset_index('hour')
# average these counts by weekend
by_hour['weekend'] = (by_hour.index.dayofweek >= 5)
by_hour = by_hour.groupby(['weekend', 'hour']).mean()
by_hour.index.set_levels([['weekday', 'weekend'],
["{0}:00".format(i) for i in range(24)]],
inplace=True);
by_hour.columns.name = None
fig, ax = plt.subplots(1, 2, figsize=(16, 6), sharey=True)
by_hour.loc['weekday'].plot(title='Hourly Rides User Type and Hour',
ax=ax[0])
by_hour.loc['weekend'].plot(title='Weekend Rides by User Type and Hour',
ax=ax[1])
ax[0].set_ylabel('Hourly Rides by User Type');
は、私が唯一の加入者と顧客のデータを取得するコードである私も、すべてのグラフの線がweekdendのためのサブとカストの両方のための時間の合計を意味し、
私は画像で示したようにグラフをプロットしたいが、できない。 – kiran
あなたはあなたが何を試したのか、何がうまくいかないのかについてより明確に答えることができますか?あなたは、1つのグラフ上の2つのプロットが問題であることを示唆しました。 – doctorlove
質問を更新しました – kiran