coloring a surface plot using custom colorbar

6 views (last 30 days)
I've developed code to plot a 3D surf plot that looks like this:
when I add the following code, the plot disappears.
shading interp
caxis([20 130])
n = 35; %// number of colors
cmap(1,:) = [0 1 0]; %// color first row - green
cmap(2,:) = [1 1 0]; %// color 12th row - yellow
cmap(3,:) = [1 0 0]; %// color 35th row - red
[X,Y] = meshgrid([1:3],[1:35]); %// mesh of indices
cmap = interp2(X([1,12,35],:),Y([1,12,35],:),cmap,X,Y);%// interpolate colormap
cmap2=repmat([1 0 0],29,1);
colormap(cmap) %// set color map
'Ticks',[20 25.2516 30 40 50.5032 60 70 75.7549 80 90 101.0065 110 120 126.2581 130],...
'TickLabels',{'20','Mean Travel Time','30','40','2*Mean Travel Time','60','70','3*Mean Travel Time','80','90','4*Mean Travel Time','110','120','5*Mean Travel Time','130'});
The set of data being represented on the mesh is an array containing vectors of values surrounded by vectors of NaNs (each vector corresponds to a day of the year, and I only want to show 1 day of every week). I had success with coloring for plotting 365 days of the year. I understand that there may be limitations in how surfaces are colored.
Any help in figuring out how to color this would be appreciated. I tried using bar3, which had some success, but I was unable to use the 'BaseValue' property that I need so that coloring doesn't begin at 0.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!