title: Why are top/bottom boxplot whiskers crooked?
body: <p>Created a box plot of (non-Gaussian) variable W_BP, and changed whisker length to encompass 1st to 99th percentile.  Problem is, the top and bottom of each whisker are crooked.  Suggestions as to how to fix?  Code and image below:</p>
  
  <p><img src="https://i.stack.imgur.com/z1e84.png" alt="Sample_Box_Plot"></p>
  
  <pre><code>clc;
  clear all;
  
  % load datafile
  load TRMM_Tropics_regression_data_pt_1mmhr_2004.mat;
  
  whos
  
  p = prctile(W_BP,[1,99]);
  figure;
  boxplot(W_BP,'whisker',2.5,'outliersize',2);
  hold on;
  
  % replace upper end y value of whisker
  h = flipud(findobj(gca,'Tag','Upper Whisker'));
  for j = 1:length(h);
      ydata = get(h(j),'YData');
      ydata(2) = p(2,j);
      set(h(j),'YData',ydata);
  end
  
  % replace all y values of adjacent value
  h = flipud(findobj(gca,'Tag','Upper Adjacent Value'));
  for j = 1:length(h);
      ydata = get(h(j),'YData');
      ydata(2) = p(2,j);
      set(h(j),'YData',ydata);
  end
  
  % replace lower end y value of whisker
  h = flipud(findobj(gca,'Tag','Lower Whisker'));
  for j = 1:length(h);
      ydata = get(h(j),'YData');
      ydata(1) = p(1,j);
      set(h(j),'YData',ydata);
  end
  
  % replace all y values of adjacent value
  h = flipud(findobj(gca,'Tag','Lower Adjacent Value'));
  for j = 1:length(h);
      ydata = get(h(j),'YData');
      ydata(1) = p(1,j);
      set(h(j),'YData',ydata);
  end
  t = title('TRMM-3B42 Cluster Area vs Cluster Power, Tropics (RR GTE 0.1mmhr), May-Sep 2004');
  set(t, 'FontWeight', 'bold', 'FontSize', 10)
  set(gca, 'FontWeight', 'bold', 'FontSize', 14)
  set(gca, 'YLim',[10^0 10^6])
  set(gca, 'YScale', 'log');
  xlabel('Bin Number');
  ylabel('Cluster Power (GW)');
  print -dpng Sample_Boxplot.png
  </code></pre>