thanks i have a solution now and it is a mix of openpyxl + pandas + matplotlib
workbook = load_workbook(excel_file,read_only=False)
worksheet = workbook['Sheet2'] # make sure this sheet exist e.g. create it before
df = pd.read_excel(excel_file, "Sheet1") #sheet 1 contains the data see above
# combine these different collections into a list
data_to_plot = [df._series['val_1']]
# Create a figure instance
fig = plt.figure(1, figsize=(8, 8))
# Create an axes instance
ax = fig.add_subplot(111)
# Create the boxplot
bp = ax.boxplot(data_to_plot)
for flier in bp['fliers']:
flier.set(marker='o', color='#e7298a', alpha=0.5)
# Save the figure
fig.savefig('val_1.png', bbox_inches='tight')
# load the created boxplot image and insert in sheet2
img = openpyxl.drawing.image.Image('val_1.png')
worksheet.add_image(img,'D3')
workbook.save(excel_file)
just one last thing i try to add the x labels as diagonal like shown here:
https://matplotlib.org/examples/pylab_examples/boxplot_demo2.html
i added these lines before : bp = ax.boxplot(data_to_plot)
xtickNames = plt.setp(ax, xticklabels="Label_1")
plt.setp(xtickNames, rotation=45, fontsize=10)
but with this i only see a single character "L" in the x axis not "Label_1"
instead of these two lines i tried this one:
ax.set_xticklabels( ['Label_1'], rotation=45 )
but it also doesnt work now i see a diagonal '1' ???