0

I begin with matplotlib and subplots. Could you tell me how to assign the 2 plots generated from this code in 2 columns:

# Bar Plot for Firm Performance
fig = plt.figure(figsize = (6, 4))
title = fig.suptitle("Firm performance", fontsize=14)
fig.subplots_adjust(top=0.85, wspace=0.3)

fig, axs = plt.subplots(1, 2)

dfSPSSactive['Q7_12_1'].value_counts().sort_index().plot(kind='bar')
dfSPSSactive['Q7_12_2'].value_counts().sort_index().plot(kind='bar', color='red')

enter image description here

Zephyr
  • 11,891
  • 53
  • 45
  • 80
fredooms
  • 123
  • 8

1 Answers1

0

You just need to pass ax parameter to pandas.DataFrame.plot:

fig, axs = plt.subplots(1, 2, figsize = (6, 4))
title = fig.suptitle("Firm performance", fontsize=14)
fig.subplots_adjust(top=0.85, wspace=0.3)

dfSPSSactive['Q7_12_1'].value_counts().sort_index().plot(ax=axs[0], kind='bar')
dfSPSSactive['Q7_12_2'].value_counts().sort_index().plot(ax=axs[1], kind='bar', color='red')

plt.show()

enter image description here

Zephyr
  • 11,891
  • 53
  • 45
  • 80