Python - How To Arrange Multiple Histograms In A Grid
The following code read each row from a numpy ndarray and create multiple histograms on the same figure: fig, ax = plt.subplots(figsize=(10, 8)) fontP = FontProperties() fontP.set_
Solution 1:
You have to use different ax
to put plot in different "cell" in "grid"
import matplotlib.pyplot as plt
import random
SIZE = 5# random data
all_data = []
for x inrange(SIZE*SIZE):
all_data.append([ random.randint(0,10) for _ inrange(10) ])
# create grid 5x5
f, ax = plt.subplots(SIZE, SIZE)
# put data in different cellfor idx, data inenumerate(all_data):
x = idx % SIZE
y = idx // SIZE
ax[y, x].hist(data)
plt.show()
Post a Comment for "Python - How To Arrange Multiple Histograms In A Grid"