CDIP banner
CDIP banner recent historic documents
sub-menu
Documentation
 
FAQs & Summaries
Glossary
Publications
 
Introduction
  History and Funding
  Program Goals
Wave Measurement
  Wave Generation
  Wave Dynamics
  Irregular Waves
  Spectral Analysis
  Gauging Waves
  Hurricane Events
  Tsunami Events
Instrumentation
  Underwater Sensors
  Surface Buoys
  Meteorological
Data Acquisition
  System Organization
  Hardware
  Software
Data Processing
  System Organization
  Software
  Quality Control
Data Management
  Stations and Sets
  Files and Storage
CDIP Products
  Data Formats
  Web Products
  COOS Integration
  QARTOD
  Wave Eval Tool
  Metadata
  Custom Products
  NDBC XML/NWS Format
  NDBC Dial-A-Buoy
  Access Instructions
 
Related Links

ANNUAL Hs BOXPLOT DESCRIPTION

A box is plotted for each month of the year that has data. The extents of the black box mark the lower quartile (25% of data values are less than this value) and upper quartile (75% of data values are less than this value), a red line indicates the median, and a dark green line indicates the mean. The black lines above and below the box, the "whiskers", show the extent of the remaining data but have a maximum length of 1.5L, where L is the length in meters from the lower quartile to the upper quartile. Data values that extend beyond the whiskers are "outliers" and are indicated with red crosses.

Source Code:


%-------------------------------------------------------------------------------
% Name:
%   .dbase/web_programs/plotpro/matlab_scripts/hsboxplot.m
% Description:
%   Creates a box plot using parameter file data, for hs
%   for each month of the year. A pid is pre-pended to this script.
% Called by:
%   .f90/plot_utils.make_plot
%-------------------------------------------------------------------------------


% ADD PATH TO ACCESS MATLAB SCRIPTS

path(path,'/project/dbase/web_programs/plotpro/matlab_scripts');

wkg = wkg_path;


months = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};

% SET-UP FIGURE

figure('position',[10 10 800 650],'visible', 'off');


% LOAD THE DATA

eval(['load ',wkg,'list.',pid,'01']);


% GET STATION INFO

info = read_info_file([pid,'01'],wkg);


% FILTER OUT MISSING VALUES

I = find(list(:,6)>=0);
list = list(I,:);

% MAKE SURE THERE IS DATA FOR EACH MONTH (if not make it -1)

mon_num = list(:,2);
hs = list(:,6);
for (i=1:12)
  idx = find(mon_num == i);
  if ( length(idx) == 0 ) 
    mon_num = [mon_num; i];
    hs = [hs; -1];
  end
end
[mon_num,I] = sort(mon_num);
mon_num
hs = hs(I);

% CREATE HS BOX PLOTS

boxplot(hs,months(mon_num)');
set(gca,'xlim',[.5 12.5]);
ylims=get(gca,'ylim');
set(gca,'ylim',[0 ylims(2)]); % change ylims
set(gca,'fontsize',12);

ylims=get(gca,'ylim'); % get new ylims
ydiff = diff(ylims);

xticks = get(gca,'xtick');

darkgreen = [.15 .65 .02];

text(0.5,0-0.08*ydiff,'N = ','horizontalalignment','center','fontsize',12);
for i=1:length(xticks)
  k = find(mon_num == xticks(i));
  num_obs(i) = length(k);
  if ( num_obs(i) == 1 & hs(k) == -1 )
    num_obs(i) = 0;
  else
    month_mean = mean(hs(k));
    line([xticks(i)-.2,xticks(i)+.2],[month_mean,month_mean],'linewidth',2, ...
      'color',darkgreen);
    mean_round = round(month_mean*10)/10;
    text(xticks(i),month_mean,num2str(mean_round),'color',darkgreen, ...
      'horizontalalignment','center','fontsize',12,'verticalalignment','bottom', ...
      'fontweight','bold');
  end
  text(xticks(i),0-0.08*ydiff,num2str(num_obs(i)), ...
    'horizontalalignment','center','fontsize',12);
end

ylabel('Significant Wave Height, Hs (m)');

year = list(1,1);
t_text2 = [ info.stnid, ' ',info.stname ];
t_text1 = ['SIGNIFICANT WAVE HEIGHT BY MONTH FOR ',num2str(year),' (UTC)'];

xlims = get(gca,'xlim');
text_x = sum(xlims)/2;
text(text_x,ylims(2)+.08*ydiff,t_text2,'horizontalalignment','center',...
  'fontsize',14);
text(text_x,ylims(2)+.03*ydiff,t_text1,'horizontalalignment','center',...
  'fontsize',14);



% MAKE A LEGEND
% scale down height of boxplot axes
ax_position = get(gca,'position')
ax_position(2) = .2;
ax_position(4) = ax_position(4)*0.85;
set(gca,'position',ax_position);



% save boxplot axes, set-up and write on new axes 
box_ah = gca;
leg_ah = axes('position', [ .27 .06 .5 .05 ],'visible','off');
x = [0 .2 .3 .3 .4 .4 .8 .8 .8 1.2 1.2];
boxplot(x,0,'+',0);

set(gca, 'visible','off');



set(gca,'ylim',[.9 1.1]);
line([.58 .58],[.94 1.06],'linewidth',2,'linestyle','-','color',darkgreen);
text(.58,.88,'MEAN','color',darkgreen);
text(.4,.88,'MEDIAN','color','r');
text(.25,.88,'25%ile');
text(.75,.88,'75%ile');
text(.55,1.12,'L (m)','color','b','fontweight','bold');
text(.9,1.05,'< 1.5');
text(1.02,1.05,'L','color','b','fontweight','bold');
text(.1,1.05,'< 1.5');
text(.22,1.05,'L','color','b','fontweight','bold');

%axes(box_ah,'visible','off');


% MAKE BLUE BOX OUTLINE AROUND PLOT

blue_box(0.01);


% PRINT TO PNG

set(gcf, 'visible','off');

png_name = [wkg,'plot_',pid,'.png'];
print('-dpng','-r75',png_name);


% ORIENT LANDSCAPE THEN ADJUST PAPER POSITION
% DUE TO LAST BLUE LINE NOT SHOWING UP ON COLOR PRINTER

orient landscape;
pp = get(gcf,'paperposition')
pp(1) = .5;
pp(3) = 10.0;
set(gcf,'paperpositionmode','manual');
set(gcf,'paperposition',pp);


% PRINT TO PS

%set(gcf, 'visible','off');
%ps_name = [wkg,'plot_',pid,'.ps'];
%print('-depsc2',ps_name);

quit;

CDIP's major funding contributors are the US Army Corps of Engineers and the California Department of Boating and Waterways.
Official UCSD Web Page