The cmap input option should allow you to specify the colors you want to use for the lines, so that you can maintain the correlation between line and patch. For example:
[hl,hp] = boundedline(1:10, rand(10,1), 0.1, 'cmap', [0.3 0.2 0.5]);
set(hl, 'linewidth', 3);
Line style, etc. still need to be modified after the fact; color is treated specially due to the link between line and patch that you point out.
Very nice script.
However, for my particular application (and perhaps for others), it would be very useful to allow the possibility of giving the line properties individually, as for plot. That is, I want to give something like:
boundedline(..., 'Color', [0.3 0.2 0.5]);
or boundedline(..., 'LineWidth', 3)
instead of the string format option (e.g. 'r-').
The advantage of that would be that I can have my own table of colors, line specs, etc. specific to each line I want to plot and I want to use that with your function to specify the properties in advance. Otherwise it is very difficult to change the color afterwards without making it totally uncorrelated (and useless) with the color of the patches you create.
Lovely function! makes pretty plots. Sadly I haven't yet found an easy way to save plots with these patches in a vectorized form. My two cents regarding NaNs. While I agree there is clearly some ambiguity as to what to do with NaNs. The complete lack of support is not consistent with the basic behavior of existing plotting functions like 'line.' Which one would like to seamlessly substitute for a function like this.
'Line' introduces a discontinuity at NaNs This implementation may be slightly more difficult with patches. But it has the benefit of both being consistent with the meaning of a NaN and very convenient for formatting plots (e.g. when the user desires to easily separate an otherwise contiguous line.)