function plot_data_31(handles)
% PLOT_DATA_31 - plots VHT and VMT data in the main screen of ctmGUI.
% Cannot be called from outside of ctmGUI.
%
% Last modified: 10/14/2006.
%
% Alex Kurzhanskiy <akurzhan@eecs.berkeley.edu>
%
global g_ctmGUI;
N = size(g_ctmGUI.cellData, 2); % number of cells
densities = g_ctmGUI.densityData(1:N, end);
flows = g_ctmGUI.flowData(1:N, end);
vht = g_ctmGUI.vhtData(1:N, end);
vmt = g_ctmGUI.vmtData(1:N, end);
delay = vht - g_ctmGUI.delayData(1:N, end);
onerow = ones(1, N);
tm = max([eps (g_ctmGUI.timeStep * g_ctmGUI.TS * 60)]);
% get Y axis limits
ymin = g_ctmGUI.timeMinutes(1);
ymax = ymin + (g_ctmGUI.TS * 60 * g_ctmGUI.taxislim * g_ctmGUI.plotPeriod);
ylim = [ymin ymax];
% assign colors to cells
clrs = get_color_grade(densities, flows, g_ctmGUI.cellData, g_ctmGUI.yoColorRatio);
axes(handles.freeway);
plotbar(g_ctmGUI.pmData, 0.5*onerow, clrs);
hold on;
idx = get(handles.onrampList, 'Value') - 1;
if (idx > 0) & (idx <= N)
plot(g_ctmGUI.pmData(idx), 0.75, 'bv', 'MarkerFaceColor', 'b');
end
idx = get(handles.offrampList, 'Value');
plot(g_ctmGUI.pmData(idx+1), 0.75, 'c^', 'MarkerFaceColor', 'c');
axis([g_ctmGUI.xLims 0 1]);
set(handles.freeway, 'YTick', []);
hold off;
% plot data (VHT and VMT)
if strcmp(get(handles.menuContoursOn, 'Checked'), 'on') % plot time contours
XX = [0 1];
mnh = min(min(g_ctmGUI.vhtData));
mxh = max(max(g_ctmGUI.vhtData));
mnm = min(min(g_ctmGUI.vmtData));
mxm = max(max(g_ctmGUI.vmtData));
myeps = 1e-7;
mxh = mxh + myeps; % these 2 lines are here to prevent
mnm = mnm - myeps; % overlaps of color maps...
uld = 2*mxh - mnh;
llf = 2*mnm - mxm;
axes(handles.flowPlot);
pcolor(g_ctmGUI.pmData, ...
[g_ctmGUI.timeMinutes tm], ...
[(g_ctmGUI.vhtData)'; (uld * [onerow 1])]);
shading flat;
if size(g_ctmGUI.timeMinutes, 2) < g_ctmGUI.taxislim
axis([g_ctmGUI.xLims ylim]);
else
ylim = axis;
ylim = ylim(3:4);
axis([g_ctmGUI.xLims ylim]);
end
%xlabel('Post mile');
ylabel('Time (min)');
axes(handles.flowCM);
YY = linspace(mnh, mxh, g_ctmGUI.numColors);
pcolor(XX, YY, [YY' (uld * ones(g_ctmGUI.numColors, 1))]);
ylabel('Vehicle Hours Traveled');
shading flat;
axis([0 1 mnh mxh]);
set(handles.flowCM, 'XTick', []);
axes(handles.densityPlot);
pcolor(g_ctmGUI.pmData, ...
[g_ctmGUI.timeMinutes tm], ...
[(g_ctmGUI.vmtData)'; (llf * [onerow 1])]);
shading flat;
if size(g_ctmGUI.timeMinutes, 2) < g_ctmGUI.taxislim
axis([g_ctmGUI.xLims ylim]);
else
ylim = axis;
ylim = ylim(3:4);
axis([g_ctmGUI.xLims ylim]);
end
xlabel('Post mile');
ylabel('Time (min)');
axes(handles.densityCM);
YY = linspace(mnm, mxm, g_ctmGUI.numColors);
pcolor(XX, YY, [YY' (llf * ones(g_ctmGUI.numColors, 1))]);
shading flat;
axis([0 1 mnm mxm]);
ylabel('Vehicle Miles Traveled');
set(handles.densityCM, 'XTick', []);
else % plot 2D data
axes(handles.flowPlot);
plotbar([g_ctmGUI.pmData(1) g_ctmGUI.pmData(2)], vht(1, 1), [0.6471 0.0549 0.1412]);
hold on;
legend('Delay portion');
plotbar(g_ctmGUI.pmData, vht', [0.6471 0.0549 0.1412]);
plotbar(g_ctmGUI.pmData, delay', [0.149 0.4353 0.1569]);
ylim = axis;
ylim = [0 ylim(4)];
axis([g_ctmGUI.xLims ylim]);
%xlabel('Post mile');
ylabel('Vehicle Hours Traveled');
hold off;
axes(handles.densityPlot);
mvmt = get_max_flows(g_ctmGUI.cellData) .* get_cell_lengths(g_ctmGUI.cellData);
mvmt = g_ctmGUI.plotPeriod * g_ctmGUI.TS * mvmt;
plotbar(g_ctmGUI.pmData, mvmt', 'w');
hold on;
plotbar(g_ctmGUI.pmData, vmt', [0.6431 0.0235 0.9765]);
hold off;
ylim = axis;
ylim = [0 ylim(4)];
axis([g_ctmGUI.xLims ylim]);
xlabel('Post mile');
ylabel('Vehicle Miles Traveled');
end
return;