image thumbnail

"Linked Plots and Data Brushing" Video: Commands and Script

by

 

28 Apr 2009 (Updated )

MATLABĀ® Commands, data files and voice-over script used in "Linked Plots and Data Brushing" video.

highway.m
%% Setup
% Import highway accident spreadsheet from highway.xls
% Tile Figure group as 4x4

%% load US coastline data
[data,textdata]=xlsread('highwayaccidents.xls');
load coastline
states=textdata(2:52,1);
columns=textdata(1,2:15);
data(end,:)=[]; % Remove average

%% Normalize 6th column to miles per vehicle
data(:,6) = 1000*data(:,6)./data(:,5);

%% Plot Miles/Vehicle vs. Fatalities/Vehicle
scatter(data(:,6),data(:,8))
xlabel('Av. Miles/Vehicle');
ylabel('Fatalities/Vehicles (x.001)');
set(gcf,'WindowStyle','docked')
linkdata

%% Plot State Positions (centroids)
figure
scatter(data(:,1),data(:,2));
hold on;
p = plot(uslon,uslat,'g');
set(p,'HandleVis','off');
set(gcf,'WindowStyle','docked')
linkdata

%% Plot Rural vs. Total Population
figure
scatter(data(:,12),data(:,14));
ylabel('Rural Population');
xlabel('Total Population');
set(gcf,'WindowStyle','docked')
linkdata

Contact us