pythonpandas

In python: How to generate only one box plot for a matrix?


This code generates 4 separate box plots. How can i generate only one box plot for the entire matrix?

data = np.random.random(size=(4,4))
df = pd.DataFrame(data)
df.boxplot()

Solution

  • if you want box plot of 16 samples (16 = 4 X 4), use following code:

    df.stack().to_frame().boxplot()
    

    enter image description here