pandas for loop grid subplots

Solutions on MaxInterview for pandas for loop grid subplots by the best coders in the world

showing results for - "pandas for loop grid subplots"
Ilyas
21 Sep 2020
1plt.figure(figsize=(10,12))
2
3for i in range(1, 7):
4    plt.subplot(3, 2, i)
5
6plt.show()
7
8
9
10#eg2
11
12
13plt.figure(figsize=(9,6))
14
15plt.subplot(3,2,1)
16plt.plot(euro_to_dollar['Time'], euro_to_dollar['US_dollar'])
17plt.title('Original values', weight='bold')
18
19for i, rolling_mean in zip([2, 3, 4, 5, 6],
20                           [7, 30, 50, 100, 365]):
21    plt.subplot(3,2,i)
22    plt.plot(euro_to_dollar['Time'],
23             euro_to_dollar['US_dollar'].rolling(rolling_mean).mean())
24    plt.title('Rolling Window:' + str(rolling_mean), weight='bold')
25    
26plt.tight_layout() # Auto-adjusts the padding between subplots
27plt.show()