I’m using some data saved in files that I want to box plot.
I have 27 values in each file (in row 3), each file I want to be an individual box plot along the x-axis for 5 ‘runs’/files.
I also then want each of those as a single boxplot for an overview as I have 10 ‘Objects’ (use all 5 files 27 values (135 values) for single boxplot)
I have started on the code but currently what I have only puts out one boxplot as I don’t think it is saving the data correctly to be able to plot multiple boxplots and thus far I have not started on combining the data for the overall graphic.
Any help would be appreciated.
` import numpy as np
from numpy import genfromtxt
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_excel("ObjectData.xlsx") #Where the names of the Objects are kept
data = []
#Iterations for objects and runs
for object in range(0, 10, 1):
for run in range(0, 5, 1):
#Access data from files
recordname1 = str(dataset.iloc[object, 1]) + " run:" + str(run) #Object and run name
path1 = recordname1 + "clonemin.csv"
my_plot_data = genfromtxt(path1, delimiter=',') #Get individual file (eg 1of10,1of5)
data = [data, np.append(my_plot_data,([3, :]))] #Get individual line from file R=3, C=all
#Save individual boxplots for plotting
fig = plt.figure(figsize=(10,7))
ax = fig.add_axes([0,0,1,1])
bp = ax.boxplot(data)
plt.show()
#Save object boxplots (1x5) iteratedx10
path2 = str(dataset.iloc[object, 1]) + "Boxplot.png"
plt.savefig(path2)
plt.clf()
path3 = "Final_Boxplot.png" #Save overall boxplots (1x10)
plt.savefig(path3)
plt.clf()
`
Result should be: For each object (10) there should be a graphic made up of 5 boxplots, and one overall graphic showing the 10 objects boxplots along the x-axis. So 11 Images overall.