So I am essentially making rainfall runoff plots, so an inverted hyetograph (rainfall) on one y axis and flow on the other. Now plotyy works great when I use an area function to describe the flow and a bar graph for the rainfall. However, when I change the word area to plot or line in the code, it makes the hydrograph look funny and screws up the bar graph. The bars are no longer closed over the appropriate time which causes the FaceColor fill to drag across the screen, its weird. Now I have worked around this, by using area plots with no fill, but I would like to understand what is happening? Here are small excerpts of the data and the code I use:
Flow93AD: This is hourly datenumbers for x values and flow rates for y values x = [728150.8333333; 728150.875000;728150.9166667;728150.9583333;728151.0000000;728151.0416667;728151.0833333;728151.1250000;728151.1666667]
y = [259.383703193410; 258.723409532005; 258.289898463849; 257.980320845167; 257.575066143656; 257.158211988047; 360.562036053458; 1992.39612523645; 4211.89982677947;]
Rain93: Uses the same date x-values as above and the y values are rainfall in inches:
y = [0; 0; 0.300000000000000; 1.40000000000000; 1.40000000000000; 0.100000000000000; 0.100000000000000; 0; 0;]
Here is the code:
x1 = datenum(1993,8,9); % Start date of the graph display
x2 = datenum(1993,8,19); % End date of the graph display
D1 = datenum(1993,8,1);D2 = datenum(1993,8,30);Selector = AllDrained(:,1)>=D1 & AllDrained(:,1) < D2;Flow93AD = AllDrained(Selector,:);Rain93 = Raindata(Selector,1:2);Flow93AUD = AllUndrained(Selector,:);Flow93Orig = OriginalDrainage(Selector,:);[AX,H1,H2]=plotyy(Rain93(:,1),Rain93(:,2),Flow93AD(:,1),Flow93AD(:,2),'bar','area');set(AX(1),'xlim',[x1,x2],'xtick',x1:x2,'FontWeight','Bold','TickDir','out'); % Sets the precipdata window, ticks and axis label properties
set(AX(1),'xtick',[]); % Removes the top plot ticks
set(AX(1),'ydir','rev','ylim',[0,3],'ytick',0:0.5:3); % Inverts the precip y axis and sets the labels
set(AX(1),'Box','Off'); % Turns of the right side tick marks from the precip axis.
set(AX(2),'xlim',[x1,x2],'xtick',x1:x2,'ylim',[0,10000],'ytick',0:1000:10000,'FontWeight','Bold','TickDir','out'); % Sets the soil hydrograph window, ticks and axis label properties
datetick(AX(1),'keeplimits'); % This changes the tick labels to dates
datetick(AX(2),'keeplimits'); set(get(AX(1),'Ylabel'),'String','Precipitation (in)','FontSize',12,'FontWeight','Bold'); % Sets the Y-axis label
set(get(AX(2),'Ylabel'),'String','Discharge (cfs)','FontSize',12,'FontWeight','Bold'); % Sets the Y-axis labelset(get(AX(1),'Xlabel'),'String','Date','FontSize',12,'FontWeight','Bold'); % Sets the Y-axis labelset(H1,'DisplayName','Precip','FaceColor','b'); set(H2,'DisplayName','Drained','FaceColor','none','EdgeColor','g');legend('show','Location','West'); % Turns the legend on
title('August 1993 Hydrograph for the One Soil All Drained Scenario','FontSize',14); % Creates a title
Once I change the word from area to plot in the plotyy function, everything screws up. Any thoughts? Thanks
Brandon
Best Answer