Я использую приведенный ниже код для создания гистограммы трех разных переменных. Я хотел бы выделить три столбца в каждой точке данных, чтобы получить лучшую визуализацию. Я попытался добавить аргумент "position" для каждой функции, но он не будет работать
count, bin_edges = np.histogram(df['age'])
fig = plt.figure(figsize=(7,3))
ax = fig.add_subplot(111) # Create matplotlib axes
df['age'].plot(kind = 'hist', figsize=(10,5), xticks = bin_edges,
width = 2, color = 'blue', alpha=0.4)
df[df['y'] == 1]['age'].plot(kind = 'hist', figsize=(10,5), xticks = bin_edges,
width = 2, color='red', alpha=0.4)
df[(df['y'] == 1)&(df['new_customer'] == 1)]['age'].plot(kind = 'hist', figsize=(10,5), xticks = bin_edges,
width = 2, color='green', alpha=0.4)
plt.title("Age")
plt.xlabel("Age Bins")
plt.ylabel("Number of Contacts")
plt.legend(loc='upper right')
plt.show()
РЕДАКТИРОВАТЬ: это то, как мой df выглядит:
df[['age', 'y', 'new_customer']]
age y new_customer
0 56 0 1
1 57 0 1
2 37 0 1
3 40 0 1
4 56 0 1
5 45 0 1
6 59 0 1
7 41 0 1
8 24 0 1
9 25 0 1
10 41 0 1
11 25 0 1
12 29 0 1
![This is what the image looks like now. I would like to have three separate columns at each age bin cutoff rather than a single stacked column](https://i.stack.imgur.com/OgtqQ.png)