function csi_load = generateLoadFigs(file, ymax, xmax)

if nargin < 2
    ymax = 1;
end
if nargin < 3
    xmax = 25;
end

% Create figure
figure1 = figure('Position', [300, 300, 340, 260]);

% Create axes
axes1 = axes('Parent',figure1);
ylim(axes1,[0 ymax]);
xlim(axes1,[0 xmax]);
box(axes1,'on');
hold(axes1,'all');

f1 = fopen(file);
c = textscan(f1, '%d', 3);
data_rows = c{1}(1);
data_cols = c{1}(2);
data_blocks = c{1}(3);


for block = 1:data_blocks
    % consume end of line
    textscan(f1, '%s', 1, 'Delimiter', '\n');

    % get label
    c = textscan(f1, '%s', 1, 'Delimiter', '\n');
    data_label = char(c{1});
    
    % skip query time data block;
    if strcmp(data_label, 'Query Time')
        textscan(f1, '%s', data_rows-1, 'Delimiter', '\n');
        continue
    end
    c = textscan(f1, '%f', data_cols);
    x_vals = cell2mat(c);
    
    % pre-allocate data matrix; rows is one less, because x-vals header
    block_data = zeros(data_rows-1, data_cols);
    
    % fill out matrix
    for row = 2:data_rows
        row_data = textscan(f1, '%f', data_cols);
        block_data(row-1,:) = cell2mat(row_data);
    end
    y_vals = mean(block_data);
    
    % calculate 95% confidence interval
    upper = zeros(data_cols,1);
    lower = zeros(data_cols,1);
    for i = 1:data_cols
        pd = fitdist(block_data(:,i), 'Normal');
        ci = paramci(pd);
        lower(i) = y_vals(i) - ci(1,1);
        upper(i) = ci(2,1) - y_vals(i);
    end
        
    % if it's the CSI load block, don't output to graph; just return it
    if strcmp(data_label, '99% Query Time')
        csi_load = [x_vals y_vals' lower upper];
        continue
    end
    
    %plot(x_vals,mean(block_data), 'DisplayName', label, 'Parent', axes1);
    h = errorbar(x_vals, y_vals, lower, upper, 'Parent', axes1, 'DisplayName', data_label);
    colorLineStyle(h(1), block-2);
    
    %hc = get(h, 'Children');
    %set(hc(1), 'linewidth', 1.5);
end

fclose(f1);

% Create xlabel
xlabel({'Query Arrival Rate (queries/sec)'});

% Create ylabel
ylabel({'Average Load'});

% Create title
title(file);

% Create legend
leg = legend(axes1,'show');
set(leg,'PlotBoxAspectRatio',[1 0.6 1]);