function plots_new(list,speeds,useleg,save_dir)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% plots_new.m produces plots that compare the mechanical variables of
% different subjects during walking.  The plots include error bars
% and have the data for each requested subject on one plot.
%
% Inputs:
% list     - list of subjects
% speeds   - vector of requested speeds
% useleg   - leg for which to plot ('L','R', or 'EMG').
% save_dir - directory to save files (leave blank to not save)
%
% Outputs:
% Just plots.
% 
% Example Usage: plots_new(['AM062411';'AD052611';'EM072611'],[125 150],'EMG','~/Desktop')
%
% Jared Markowitz
% Summer 2011
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%colors = ['b';'r';'k';'m';'g';'c';'y'];

colors = [0.0 0.0 0.0;
          0.0 0.0 1.0;
          1.0 0.0 0.0;
          0.0 0.5 0.2;
          0.5 0.0 1.0;
          1.0 0.6 0.0;
          0.4 0.4 0.4
          0.0 0.1 0.5;
          .95 .85 0.0;
          0.8 0.0 0.8;
          .45 0.3 0.0
          0.0 0.3 0.1];

addpath('~/Dropbox/harvard/processMOT');
close all;

leg_cmd = 'legend(''';
for h = 1:size(list,1)
  if h < size(list,1)
    leg_cmd = [leg_cmd list(h,:) ''',''']; 
  else
    leg_cmd = [leg_cmd list(h,:) ''',''location'',''best'');'];
  end;  
end;

for i = 1:size(speeds,2)
  if speeds(i) == 75;
    numstr = '075';
  else
    numstr = num2str(speeds(i));
  end;
  
  for j= 1:size(list,1)
    path_full = ['~/Documents/MATLAB/data/' list(j,:) '/processed/mot/mat/all/'];
    eval(['load ' path_full 'walk' numstr '.mat']);

    if exist('useleg')==0 || strcmp(useleg,'EMG')==1
      useleg1 = EMGleg;
    else
      useleg1 = useleg;
    end;

    eval(['m_ankle_ang = m_ankle_ang_' lower(useleg1) ';']);
    eval(['m_ankle_mom = m_ankle_mom_' lower(useleg1) ';']);
    eval(['m_knee_ang = m_knee_ang_' lower(useleg1) ';']);
    eval(['m_knee_mom = m_knee_mom_' lower(useleg1) ';']);
    eval(['m_hip_ang = m_hip_ang_' lower(useleg1) ';']);
    eval(['m_hip_mom = m_hip_mom_' lower(useleg1) ';']);
    eval(['sd_ankle_ang = sd_ankle_ang_' lower(useleg1) ';']);
    eval(['sd_ankle_mom = sd_ankle_mom_' lower(useleg1) ';']);
    eval(['sd_knee_ang = sd_knee_ang_' lower(useleg1) ';']);
    eval(['sd_knee_mom = sd_knee_mom_' lower(useleg1) ';']);
    eval(['sd_hip_ang = sd_hip_ang_' lower(useleg1) ';']);
    eval(['sd_hip_mom = sd_hip_mom_' lower(useleg1) ';']);
  
    numpts = length(m_ankle_ang_r);

    eval(['figure(' num2str(i) num2str(1) ');']);
    subplot(3,2,1)
    hold on; 
    eval(['niceBars(0:(numpts-1),m_ankle_ang,sd_ankle_ang,[' num2str(colors(j,:)) '],0.5);']);
    subplot(3,2,2)
    hold on; 
    eval(['niceBars(0:(numpts-1),m_ankle_mom,sd_ankle_mom,[' num2str(colors(j,:)) '],0.5);']);
    subplot(3,2,3)
    hold on; 
    eval(['niceBars(0:(numpts-1),m_knee_ang,sd_knee_ang,[' num2str(colors(j,:)) '],0.5);']);
    subplot(3,2,4)
    hold on; 
    eval(['niceBars(0:(numpts-1),m_knee_mom,sd_knee_mom,[' num2str(colors(j,:)) '],0.5);']);
    subplot(3,2,5)
    hold on; 
    eval(['niceBars(0:(numpts-1),m_hip_ang,sd_hip_ang,[' num2str(colors(j,:)) '],0.5);']);
    subplot(3,2,6)
    hold on; 
    eval(['niceBars(0:(numpts-1),m_hip_mom,sd_hip_mom,[' num2str(colors(j,:)) '],0.5);']);
  end;

  eval(['figure(' num2str(i) num2str(1) ');']); 
  subplot(3,2,1)
  axis tight;
  title('Ankle Angle');
  xlabel('Percent GC','fontsize',12);
  ylabel('Dorsi. Ang.(^\circ)','fontsize',12);
  legend('BC','DC','DH','JB','MC','location','eastoutside');
  h_xlabel = get(gca,'XLabel');
  set(h_xlabel,'FontSize',14); 
  h_ylabel = get(gca,'YLabel');
  set(h_ylabel,'FontSize',14); 
  h_title = get(gca,'Title');
  set(h_title,'FontSize',14); 
  set(gca,'fontsize',14)
  set(gca,'linewidth',2)
  subplot(3,2,2) 
  axis tight;
  title('Ankle Moment');
  xlabel('Percent GC','fontsize',12);
  ylabel('Dorsi. Mom. (Nm)','fontsize',12);
  legend('BC','DC','DH','JB','MC','location','eastoutside');
  h_xlabel = get(gca,'XLabel');
  set(h_xlabel,'FontSize',14); 
  h_ylabel = get(gca,'YLabel');
  set(h_ylabel,'FontSize',14); 
  h_title = get(gca,'Title');
  set(h_title,'FontSize',14); 
  set(gca,'fontsize',14)
  set(gca,'linewidth',2)
  subplot(3,2,3)
  axis tight;
  title('Knee Angle');
  xlabel('Percent GC','fontsize',12);
  ylabel('Flex. Ang.(^\circ)','fontsize',12);
  legend('BC','DC','DH','JB','MC','location','eastoutside');
  h_xlabel = get(gca,'XLabel');
  set(h_xlabel,'FontSize',14); 
  h_ylabel = get(gca,'YLabel');
  set(h_ylabel,'FontSize',14); 
  h_title = get(gca,'Title');
  set(h_title,'FontSize',14); 
  set(gca,'fontsize',14)
  set(gca,'linewidth',2)
  subplot(3,2,4)
  axis tight;
  title('Knee Moment');
  xlabel('Percent GC','fontsize',12);
  ylabel('Flex. Mom. (Nm)','fontsize',12);
  legend('BC','DC','DH','JB','MC','location','eastoutside');
  h_xlabel = get(gca,'XLabel');
  set(h_xlabel,'FontSize',14); 
  h_ylabel = get(gca,'YLabel');
  set(h_ylabel,'FontSize',14); 
  h_title = get(gca,'Title');
  set(h_title,'FontSize',14); 
  set(gca,'fontsize',14)
  set(gca,'linewidth',2)
  subplot(3,2,5)
  axis tight;
  title('Hip Angle');
  xlabel('Percent GC','fontsize',12);
  ylabel('Flex. Ang.(^\circ)','fontsize',12);
  legend('BC','DC','DH','JB','MC','location','eastoutside'); 
  h_xlabel = get(gca,'XLabel');
  set(h_xlabel,'FontSize',14); 
  h_ylabel = get(gca,'YLabel');
  set(h_ylabel,'FontSize',14); 
  h_title = get(gca,'Title');
  set(h_title,'FontSize',14); 
  set(gca,'fontsize',14)
  set(gca,'linewidth',2)
  subplot(3,2,6)
  axis tight;
  title('Hip Moment');
  xlabel('Percent GC','fontsize',12);
  ylabel('Flex. Mom. (Nm)','fontsize',12);
  legend('BC','DC','DH','JB','MC','location','eastoutside');
  h_xlabel = get(gca,'XLabel');
  set(h_xlabel,'FontSize',14); 
  h_ylabel = get(gca,'YLabel');
  set(h_ylabel,'FontSize',14); 
  h_title = get(gca,'Title');
  set(h_title,'FontSize',14); 
  set(gca,'fontsize',14)
  set(gca,'linewidth',2)
end;  

addpath ~/Desktop/export_fig
set(gcf,'Color',[1,1,1])
keyboard
export_fig sub_ang_mom -png