File Exchange

image thumbnail

Add a background gradient to plots

version 1.1.0.0 (122 KB) by Michelle Hirsch
Add a background gradient to plot axes to make them look a little fancy.

15 Downloads

Updated 17 Aug 2015

GitHub view license on GitHub

The picture pretty much says it all. This is a simple function for adding a nice looking background gradient on your plots. It's useful for making things look a little fancy.
Note: The author does not condone the fancification of plots to make up for a complete lack of substance!

Good luck :)

Comments and Ratings (13)

Thanks for the fix, Benjamin. I just integrated it and pushed this up to GitHub.

if you don't want your grid to be covered by the background patch, add this line at the end of the code:
set(gca,'Layer','top')

Cool idea, Weidong. I don't have time to work on this but I welcome a pull request on GitHub from anybody who wants to take a stab at it.

weidong Li

It is wonderful. Is it likely to make the gradient varying diagonally from the origin to the max. X and Y?

rcbb

Luca Broggi

Really useful!

Interesting, Yasser. I'm having a hard time picturing how this would work for 3D plots. Do you envision gradients along the box boundaries, or perhaps a transparent cube with a gradient, or maybe something else?

Yasser

Hi,

would it be possible to make it for 3D plots?

Thanks
Yasser

All - Jan pointed out the issue to me, where the gradient covered everything else in your plot. I posted the update to GitHub.

Jan
Hmmm, this is working fine for me. Are you using the version from GitHub? I updated it last June.

If you are using the latest version and still having issues, please let me know what error message you get.

Here's a direct link to the GitHub repository:
https://github.com/michellehirsch/Add-Background-Gradient-to-MATLAB-Plots/blob/master/addgradient.m

Please can you adapt your function for R2014b? Your example doesn't work:
clf
plot(10*rand(1,100));
addgradient

Updates

1.1.0.0

Re-hosted on GitHub.

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux