Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Conditionally colored line plot

4.5 | 2 ratings Rate this file 21 Downloads (last 30 days) File Size: 3.76 KB File ID: #30423 Version: 1.0
image thumbnail

Conditionally colored line plot


Matt Tearle (view profile)


Plots (2D line) graph split into two colors above and below a given threshold value

| Watch this File

File Information

Plots vectors x & y using one color for when y is greater than a given threshold value, and another color when y is less than the threshold.

You can optionally specify any standard formatting string that PLOT accepts (eg 'rx:' for a red dotted line with cross markers).

The plotting follows the standard MATLAB PLOT approach of linearly interpolating between data values. The coloring/linestyle changes at y = threshold, even on the interpolated line.


This file inspired Conditionally Colored Plot (Ccplot).

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
13 Mar 2014 Barnaby

Barnaby (view profile)

15 Jun 2012 Jeremy

Jeremy (view profile)

  • 1 file
  • 4.84615

It works well as described, but could be improved by handling multiple thresholds.

Contact us