View License

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

» Watch video

Highlights from
Conditionally colored line plot

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.66667
4.7 | 3 ratings Rate this file 12 Downloads (last 30 days) File Size: 3.76 KB File ID: #30423 Version: 1.0.0.1
image thumbnail

Conditionally colored line plot

by

Matt Tearle (view profile)

 

15 Feb 2011 (Updated )

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

| Watch this File

File Information
Description

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.

Acknowledgements

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 (3)
18 Jun 2016 Iliana Cardenes

HI!!

Thank you for this function! :)

Is there a way to apply it when Y has more than one vector in it? So when every line exceeds a threshold then it changes the colour?

Another question, is there a way for the threshold to apply to the index in X and not the values in Y? So the threshold would appear vertically, not horizontally?

Thank you so much!

Iliana

13 Mar 2014 Barnaby

Barnaby (view profile)

 
15 Jun 2012 Jeremy

Jeremy (view profile)

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

Updates
01 Sep 2016 1.0.0.1

Updated license

Contact us