R から作業例を翻訳するだけで、Python (iPython) で ggplot を動作させようとしています。ただし、多くの警告/エラーが発生します。いくつかいじった後、グラフを作成しましたが、Rで作成したものとはまったく異なるものとして終了しました.Rコードは次のとおりです。
require(ggplot2)
example = read.table('exampleData.txt', header=TRUE, sep='\t')
ggplot(data=example, aes(x=case, y=H, fill=factor(type))) +
geom_bar(position=position_dodge(.9), width=0.5,
binwidth=0.5, stat='identity') +
scale_x_discrete('Case') +
scale_y_continuous('H')
これにより、素敵な図が生成されます。
ただし、Python で同じものを取得することはできません。エラーメッセージが多すぎるため、上の図とはまったく異なるものを作成しました。Python コードは次のとおりです。
from itertools import izip, chain, product
import pandas as pd
import numpy as np
from ggplot import *
example = pd.DataFrame(np.genfromtxt('exampleData.txt', names=True, dtype=None))
print ggplot(aes(x='case', y='H', fill='factor(type)'), data=example) +\
geom_bar()
お願いします、これで私を助けてくれますか? また、Python でのプロットに関する包括的なものはありますか? また、R と Python での ggplot の比較ハウツーはありますか?