I am trying to produce a figure in Matlab suitable for publication, and I need some help with the colorbar.
My data ranges from -20 to 30, but I want the colorbar to focus on -15 to 15, with arrows at each end to represent values outside that range.
I have tried using the class "pointyColorbar" (http://www.mathworks.co.uk/matlabcentral/answers/48773) but it doesn't produce the required output. Ideally, I would like the colorbar to look like the one below, but using my custom colormap.
Can anyone help me out with this? Sorry if I haven't asked the question right - I am new to this!
As requested, below is what I currently have for my colorbar (cmap is my custom color map):
cmap=precipanomcolourmap(7,7)
colormap(cmap)
caxis([-20 30])
cb=colorbar('location','southoutside');
set(get(cb,'title'),'string','Average annual precipitation anomaly (%)','FontWeight','bold');
set(cb,'XTick',[-17.5 -15 -12.5 -10 -7.5 -5 -2.5 0 2.5 5 7.5 10 12.5 15 17.5]);
xlim(cb,[-17.5 17.5]);
This gets me a rectangular colorbar below my figure ranging from -17.5 to 17.5. The values outside of this are marked using the same colour as the +/- 15-17.5 range.
When I tried the pointyColorbar class, I replaced the cb=colorbar('location','southoutside');
line with cb=pointyColorbar(15,-15,'location','southoutside')
. It may well be that I need to play around with how to use the pointyColorbar class, but I don't understand the code well enough to know how to get it to look how I want it.
isrow
andiscolumn
in the pointyColorbar are only available from MATLAB R2011a. Also, thepoly2mask
function is available in the Image Processing Toolbox, so the class won't work if you don't have that toolbox. – m_powercontour
function. – m_power