回答編集履歴
2
コメントを受けて回答を修正
test
CHANGED
@@ -81,3 +81,77 @@
|
|
81
81
|
|
82
82
|
|
83
83
|
![イメージ説明](74c708aecf9a71264a3654def5352a7b.png)
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
---
|
88
|
+
|
89
|
+
**【追記】**
|
90
|
+
|
91
|
+
Y軸の値に3桁区切りをつけるには、(もう一つの質問で回答した)`FuncFormatter()` で変換するのが簡単です。
|
92
|
+
|
93
|
+
```Python
|
94
|
+
|
95
|
+
plt.gca().get_yaxis().set_major_formatter(ticker.FuncFormatter(lambda v,p: f'{int(v):,d}'))
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
修正済みサンプルコード
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
import pandas as pd
|
106
|
+
|
107
|
+
import numpy as np
|
108
|
+
|
109
|
+
import matplotlib.pyplot as plt
|
110
|
+
|
111
|
+
import matplotlib.ticker as ticker
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
N = 10
|
116
|
+
|
117
|
+
x = pd.date_range('2020/1/1 0:00', periods=N, freq='1d')
|
118
|
+
|
119
|
+
y = np.random.randint(10,100,N) * 1000
|
120
|
+
|
121
|
+
y2 = np.random.randint(10,100,N) * 1000
|
122
|
+
|
123
|
+
left = np.arange(N)
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
height1 = y
|
128
|
+
|
129
|
+
height2 = y2
|
130
|
+
|
131
|
+
labels = x.date
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
width = 0.4
|
136
|
+
|
137
|
+
plt.xticks(x, rotation=90)
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
plt.bar(left, height1, color='r', width=width, align='center',label='y')
|
142
|
+
|
143
|
+
plt.bar(left+width, height2, color='b', width=width, align='center',label='C')
|
144
|
+
|
145
|
+
plt.legend(loc = 'upper right')
|
146
|
+
|
147
|
+
plt.xticks(left + width/2, labels)
|
148
|
+
|
149
|
+
plt.gca().get_yaxis().set_major_formatter(ticker.FuncFormatter(lambda v,p: f'{int(v):,d}'))
|
150
|
+
|
151
|
+
plt.tight_layout()
|
152
|
+
|
153
|
+
plt.show()
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
![イメージ説明](762297fdd109cab4820f4886559461be.png)
|
1
サンプルに余分なinportがあったので削除
test
CHANGED
@@ -31,8 +31,6 @@
|
|
31
31
|
import numpy as np
|
32
32
|
|
33
33
|
import matplotlib.pyplot as plt
|
34
|
-
|
35
|
-
import matplotlib.dates as mdates
|
36
34
|
|
37
35
|
|
38
36
|
|