Search code examples
pythonboxplotshow

Boxplot: how to not show the plot?


A very basic question:

I create a boxplot from a dictionary and just want to assign the result to a variable; for example:

import matplotlib.pyplot as plt
df = {'A': [34.54, 34.345, 34.761], 'B': [34.541, 34.748, 34.482]}
bp = plt.boxplot(df.values())

I didn't use instruction plt.show(), nevertheless the plot is shown by defaut, although I don't want it. Is there a special way to instruct the program not show the plot?


Solution

  • To not show the plot, use the plt.close() function.