No BSD License  

Highlights from
Shade area between two curves

4.66667

4.7 | 31 ratings Rate this file 206 Downloads (last 30 days) File Size: 1.83 KB File ID: #13188
image thumbnail

Shade area between two curves

by John Bockstege

 

30 Nov 2006 (Updated 30 Nov 2006)

Function shades the area between two vectors.

| Watch this File

File Information
Description

This routine will shade the area of a 2-D plot between two user defined vectors. Simply pass the two vectors, and their corresponding horizontal coordinates, select your fill color and transparency level and viola! You have a figure that is colored in between the two input vectors.

Acknowledgements
This submission has inspired the following:
Simpsons Rule Demonstration, "Greater Than" Fill
MATLAB release MATLAB 7.3 (R2006b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (33)
11 Dec 2006 Francis Hossmeyer

Great! Solves a common problem.

19 Jan 2007 Chris Klink

Works great, but apparently only when datapoint are horizontally organized (one row). If it's a column it doesn't work. You could mention this in the file.

13 Mar 2007 Matthias Brunner

Very nice. Thanks!

01 Aug 2007 Marc Ferrer

Wonderful function.

31 Aug 2007 H W

Exactly what I needed. Thanks for posting!

02 Oct 2007 Luke Taylor

Just what I needed. Thanks!

08 Dec 2007 Housam binous

Great job. Thanks for all.

06 Feb 2008 M H

lovely function but it is removing box around figure as consequence of transparency.

20 Feb 2008 W. H. Brave

Very good file, thank you.

13 Mar 2008 maka mohu

if you make I run the following example, matlab logs me off my user account on SuSe 10.2

for i=1:25
  figure
  % copy the jbfill.m example from the comments here.
  close
end

07 May 2008 Ta M

Thanks, exactly what I needed!
Also thanks to Chris: put data in row vectors!

26 May 2008 W. Johns

Good file, but the colour disappears when I switch to a vertical log scale. How can I fix this?

06 Aug 2008 Yasser Soliman

Great. This was very helpful and saved me lots of time to figure out the exact work that you've done. Thanks!
On another note, I need a few vector-couples the area between which need to be shadded, on the same plot. How can I incorporate that?

05 Sep 2008 Luis Concha

Very, very helpful and extremely easy to use. Great for confidence intervals!

11 Feb 2009 ursula larke

thank you!!!! this came in REALLY handy! easy to use, well documented! :)

06 Apr 2009 Ueli Rutishauser  
07 Apr 2009 Ueli Rutishauser

works great,thanks!
the "transparancy" option comes with a caveat: it will switch the renderer to opengl. After that, a vector export is not possible anymore (matlab limitation). set to 1.0 to avoid this problem.

10 Jun 2009 Andranik Valedi

Beautiful.

04 Oct 2009 Matlaboscope

good but row vectors VS column vectors as input does matter.

18 Nov 2009 SRG  
21 Apr 2010 Robert Cumming

very good, and commented well (does what it says on the tin)

25 May 2010 Redmond

This function is great, thanks very much. I was hoping to use it to highlight the time-periods for which there was a statistical difference between the two lines. After creating the basic plot, I created a new matrix which specifies the time-points of interest (statistcially significant) in the first column, and the relevant data points for the two lines in the 2nd and 3rd column. I then ran jbfill on this. Unfortunately because the periods of interest are non-contiguous the function fills in the area in between. Is there a way to make it so that it wil only shade in areas at the specific time-points I have specified?

16 Aug 2010 Grzegorz Knor

Very smart solution.

30 Sep 2010 Ulrich Sachs

Very nice. But because of the transparancy, Matlab switches to OpenGL, which leads to vanishing axis. To avoid that I just make the axis lines thicker set(gca,'LineWidth',1.0).
Because logarithmic plots do not support OpenGL, you can not draw transparant areas in logarithmic plots.

23 Oct 2010 Jakob

Simple and straight forward! Just what I needed.

18 Feb 2011 Juan

great

29 Jun 2011 Brais

nice function, nice help, straightforward use

28 Oct 2011 cehc84  
04 Nov 2011 Clara

Easy to use, and very useful... at least for those of us working in geophysics. Thanks

17 Dec 2011 Javad

TERRIFIC! Thanks.

03 Jan 2012 Timothy Kinyanjui

Great function

16 Jan 2012 Vincent

Works great, thanks!

04 Feb 2012 Stephan  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
specialized John Bockstege 22 Oct 2008 08:50:53
plotting John Bockstege 22 Oct 2008 08:50:53
fill John Bockstege 22 Oct 2008 08:50:53
area John Bockstege 22 Oct 2008 08:50:53
curves John Bockstege 22 Oct 2008 08:50:53
shade John Bockstege 22 Oct 2008 08:50:53
graphics John Bockstege 22 Oct 2008 08:50:53
shading Gautam Vallabha 17 Jun 2009 11:12:02
shade ismail fourari 09 Jul 2009 09:26:01
shading ismail fourari 09 Jul 2009 10:49:55
plotting SRG 18 Nov 2009 16:54:51
graphics SRG 18 Nov 2009 16:54:58
fill SRG 18 Nov 2009 16:55:01
shade SRG 18 Nov 2009 16:55:04
shading Roland Jacobus 14 Mar 2010 22:10:13
area Todd 23 Apr 2010 15:33:12
fill Anywhere 06 May 2010 12:21:23
area Anywhere 06 May 2010 12:21:38
shade gabbaging 04 Jun 2010 06:34:39
curves Caroline Normile 15 Jun 2010 13:32:58
fill Stian 12 Apr 2011 13:05:38
plotting Sophie 24 May 2011 22:18:35
area Nhu Che 03 Jun 2011 01:25:38
curves Nhu Che 03 Jun 2011 01:25:42
area Nhu Che 05 Jun 2011 04:15:10
area Danny 03 Aug 2011 01:40:54
area Marie Devaine 09 Aug 2011 05:51:11

Contact us at files@mathworks.com