plot array starting or ending with nan

I need to plot some arrays that may begin or end with nan's. Currently, mpl
does a good job handling something like plot([1,2,nan,4]), but the has
trouble with plot([nan,2,3,4]) and plot([1,2,3,nan]).

Could somebody point me in the right direction: where can I look in the
sourcecode to learn how mpl deals with plotting nans?