私のggplotフィギュアにはいくつかの問題があります。良いデータがあるように見えますが、プロットは値を取っていません。
データは次のとおりです。
In[127]: ts_top10_stk
Out[127]:
type value
unit
R084 entriesn_hourly 1868674
R084 exitsn_hourly 1467338
R022 entriesn_hourly 1773372
R022 exitsn_hourly 1483494
R012 entriesn_hourly 1618262
R012 exitsn_hourly 1084521
R046 entriesn_hourly 1555117
R046 exitsn_hourly 968557
R055 entriesn_hourly 1554806
R055 exitsn_hourly 1174953
R033 entriesn_hourly 1534652
R033 exitsn_hourly 843390
R018 entriesn_hourly 1444569
R018 exitsn_hourly 1200120
R011 entriesn_hourly 1355492
R011 exitsn_hourly 484352
R029 entriesn_hourly 1347727
R029 exitsn_hourly 771924
R179 entriesn_hourly 1270579
R179 exitsn_hourly 415908
プロットのために私がそれを使ってやっていることは次のとおりです。
plot_top10 = ggplot(aes(x = 'unit',y='value',fill='type'),data=ts_top10_stk) + geom_bar()
この例外を取得する:
Exception: Could not evaluate the 'x' mapping: 'unit' (original error: name 'unit' is not defined)
明らかに、x 軸に単位があり、エントリーとエグジットの間で棒が分割された積み上げ棒グラフを作成しようとしています。ggplot の概念が欠けているように感じます。
その他の情報は次のとおりです。
In[202]: ts_top10_stk.columns
Out[202]: Index([u'type', u'value'], dtype='object')
In[203]: ts_top10_stk.index
Out[203]:
Index([u'R084', u'R084', u'R022', u'R022', u'R012', u'R012', u'R046', u'R046',
u'R055', u'R055', u'R033', u'R033', u'R018', u'R018', u'R011', u'R011',
u'R029', u'R029', u'R179', u'R179'],
dtype='object', name=u'unit')
更新: 単位値の新しい列を作成しました:
ts_top10_stk['unit2'] = ts_top10_stk.index
plot_top10 = ggplot(aes(x = 'unit2',y='value',fill='type'),data=ts_top10_stk) + geom_bar()
ここに私が得ているものがあります-まだ実際の値を考慮していません...カウントを取り、それをプロットしているように見えます(それぞれに1つ、合計2つのタイプ):