0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pandasのplotでグラフを横に並べる

Last updated at Posted at 2022-12-22

pandasのplotで棒グラフと円グラフを横に並べて表示してみたいと思います

データ

A
0 test
1 train
2 test
3 train
4 train

コードはこちら
いくつかの記事ではaxesの要素数が2だったりするが、1行の場合は[0,1]の様な書き方はエラーとなった

fig, axes = plt.subplots(1,2,figsize=(12, 6)) # 1行2列
df["A"].value_counts().plot(ax=axes[0],kind='bar')
df["A"].value_counts().plot(ax=axes[1],kind='pie',autopct="%.f%%",startangle=90,counterclock=False,ylabel="")
plt.show()

output.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?