View License

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

» Watch video

Highlights from

5.0 | 2 ratings Rate this file 6 Downloads (last 30 days) File Size: 3.43 KB File ID: #23439 Version: 1.1
image thumbnail




26 Mar 2009 (Updated )

Create a 3-dimensional barchart where the height of the bar chooses the color.

| Watch this File

File Information

The bar3 function was modified to make the color map variable, cc, match the height variable, zz. The cc variable has the height for each of the faces of the bar. Seven lines of code were added to bar3 to modify the color map.


This file inspired Superbar.

MATLAB release MATLAB 8.4 (R2014b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
09 Jul 2013 Dennis

Dennis (view profile)

25 Nov 2012 Eran Mukamel

17 Apr 2012 Marty Schlosser

The few lines of code above by 'us' do a good quick job for color varying with bar height, but the entire bar does not color in like the function bar3color will.

Is there a way to create a stacked bar using the same colors used in a bar3color of a given data set? For example, if I use:

hh = bar3color(peaks(3));

I get a 3x3 plot whose bars are colored as a function of their height. I'd like to keep these same colors, for the same data, and stack the rows (or columns) so that the new stacked bar plot shows the total height, but each bar contributing to its total has the color used in the previous bar3color plot.

I want to do this so I can condense a bunch of information that I have on a bar3color plot into two dimensions and keep the coloring scheme so the eye can move easily between the same data on two different plots.

Comment only
27 Mar 2009 us

us (view profile)

these few lines do the same without need to change BAR3...

% create a stock bar3
% the engine
for i=1:length(bh)
% choose your color...


Comment only
31 Mar 2016 1.1

Updated the file so that it now has the BSC license. It is a minor modification of the existing bar3() function.

Contact us