i'm writing python function produce boxplots of data using python's matplotlib. require function dynamically determine number of figures , subplots based on number of columns in data. make figures readable want maximum number of subplots 4 4. if there more 16 want function fill many 4 4 figures necessary partially fill final figure remainder.
for example, data have has 43 columns. therefore want function produce 2 full figure containing 16 subplots each , 1 partially filled figure containing remaining subplots. problem stuck logic of writing such function.
my code:
import matplotlib.pyplot plt def boxplot_data(self,parameters_file): data = read_csv(parameters_file) header = data.keys() number_of_full_subplots = len(header)/16 remainder = len(header)-(16*number_of_full_subplots) in range(0,number_of_full_subplots): plt.figure(i) j in range(0,16): plt.subplot(4,4,j) boxplot(data[header[0:16]]) my plan iterate on 'full subplots' first iterate on remainder method produces 2 identical figures.
does have suggestions?
thanks
the figures identical because line
boxplot(data[header[0:16]]) does not change when i , j incremented.
replace
boxplot(data[header[16*i+j]]) import matplotlib.pyplot plt def boxplot_data(self, parameters_file): data = read_csv(parameters_file) header = data.keys() number_of_full_subplots = len(header)/16 in range(number_of_full_subplots): plt.figure(i) j in range(16): plt.subplot(4, 4, j) boxplot(data[header[16*i+j]])
Comments
Post a Comment