0

I have a dataframe in the following format:

enter image description here

and I'm trying to boxplot it using the following code:

plot = toPlot.boxplot(column=['Score'], by=['Q1','Q2'])
plt.show()

which gives me the following plot:

enter image description here

As we can see in the above plot, the result has (T,F), (T,T), (F,T) etc combinations already made, which I don't want for my purposes.

I'd ideally like the following:

Plot these box plots separately like the graph below (which has been taken from here) plots it. But I have multiple Q1, Q2....Qn etc. So I'd like to have these individual plots in rows and columns, more like a scatterplotmatrix or facet_grid in R.

enter image description here

Any pointers on how to achieve this?

TIA.

Patthebug
  • 4,647
  • 11
  • 50
  • 91

1 Answers1

1
fig = plt.figure()
ax1 = plt.subplot(1,2,1)
df.boxplot(column='Score',by='Q1',ax=ax1)
ax2 = plt.subplot(1,2,2)
df.boxplot(column='Score',by='Q2',ax=ax2)
fig.suptitle('test title', fontsize=20)
plt.show()
michael_j_ward
  • 4,369
  • 1
  • 24
  • 25
  • Thank you. The code worked fine but when I tried to extend this to the entire data frame having 27 columns, it failed and gave me an error. Details are explained on a separate SO question - http://stackoverflow.com/questions/37799865/grouper-for-columnname-not-1-dimensional – Patthebug Jun 13 '16 at 22:04