teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

d

2021/01/22 10:34

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -41,4 +41,51 @@
41
41
  ax.set_xticks([], minor=True)
42
42
  ```
43
43
 
44
- ![イメージ説明](5f959f3b42d3d3e2662026922959b8b8.jpeg)
44
+ ![イメージ説明](5f959f3b42d3d3e2662026922959b8b8.jpeg)
45
+
46
+ ## 追記
47
+
48
+ ```python
49
+ import pandas as pd
50
+
51
+ df = pd.DataFrame(
52
+ {
53
+ "Store": [
54
+ "shop1",
55
+ "shop2",
56
+ "shop3",
57
+ "shop4",
58
+ "shop5",
59
+ "shop6",
60
+ "shop7",
61
+ "shop8",
62
+ "shop9",
63
+ "shop10",
64
+ ],
65
+ "Guest": [45, 132, 78, 154, 39, 57, 83, 117, 96, 44],
66
+ "Outer": [0, 4, 1, 5, 0, 1, 0, 8, 2, 0],
67
+ "Tops": [3, 11, 5, 18, 1, 2, 4, 15, 12, 3],
68
+ "Bottoms": [1, 8, 3, 12, 1, 3, 8, 10, 8, 0],
69
+ "Inner": [3, 7, 10, 8, 2, 5, 6, 1, 0, 5],
70
+ "Shoes": [0, 2, 0, 5, 0, 1, 1, 3, 0, 0],
71
+ }
72
+ )
73
+
74
+ df = df.set_index("Store")
75
+
76
+ axes = df.plot(kind="bar", figsize=(10, 15), subplots=True)
77
+
78
+ # 図の縦方向のスペース調整
79
+ axes[0].get_figure().subplots_adjust(hspace=0.5)
80
+
81
+ for ax in axes:
82
+ # タイトルを消す
83
+ ax.set_title("")
84
+ # ラベルを下に表示
85
+ ax.tick_params(labelbottom=True)
86
+ # ラベルを回転
87
+ for tick in ax.get_xticklabels():
88
+ tick.set_rotation(90)
89
+ ```
90
+
91
+ ![イメージ説明](3c504a417e0b18d099ed54e72fd4680a.jpeg)

1

s

2021/01/22 10:34

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -1,6 +1,8 @@
1
+ `df.plot()` は作成した図 (Axes) をリストで返します。
2
+ その各 Axes に対して、以下を呼び出すと
1
3
  `Axes.set_xticks([])` で major の目盛り
2
4
  `Axes.set_xticks([]. minor=True)` で minor の目盛り
3
- 各図 (Axes) の x 軸の目盛りを消せます。
5
+ を消せます。
4
6
 
5
7
  [matplotlib - 目盛、目盛のラベル、グリッドの設定方法について](https://pystyle.info/matplotlib-ticks-and-grid/#outline__3)
6
8