How to use non-symmetric linewidth on a plot

Say I have the following:
upperbound = .001"
lowerbound = .003"
xdata = 1:.1:10
ydata = f(xdata)
I would like to plot(xdata,ydata) with a linewidth that is not symmetric. More specifically, I would like to have a shaded 'tube' with a maximum values of ydata + upperbound, and minimum values of ydata - lowerbound.
I've attached a picture to help explain what I'm trying to do. The only thing I would add is that I would like to have the space between the upper and lower bound shaded in.

 Réponse acceptée

shadecolor = [.1 .2 .3];
fill([xdata, fliplr(xdata)], [ydata + upperbound, fliplr(ydata - lowerbound)], shadecolor);
So draw across the top, down to the bottom right, backwards across the bottom, automatically closes to original point.

2 commentaires

Ryan Liu
Ryan Liu le 9 Juin 2015
Thanks for this response Walter! I didn't know about the fill command.
I'm still having some issues with my plot, but I think it's an issue with my data structure, and not the plotting method
Ryan Liu
Ryan Liu le 9 Juin 2015
Update for others reading my post: I managed to fix my issues by making the entities of my array horizontal (i.e. a 1xn array). Instead of using 'fill' I used 'patch' so I could plot one patch on top of another. I also needed to get rid of NaN entities from my arrays.
Thanks for your help Walter. You're awesome!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by