good day! Help me please. How can i get rid of the yellow color in this attached contour filled plot?. Thanks.

good day! Help me please. How can i get rid of the yellow color in this attached contour filled plot?. Thanks.

5 Comments

Okay. Basically i just applied a contourf function over a somewhat projection with the code:
m_contourf(lon,lat,data(lat,lon),[-20.5:-10.5])
Please take note that I tried restricting the axis limits of the contour i.e. [-20.5:-10.5] as the aim was to get rid of all values above -10.5
Thanks.
Okay. Basically i just applied a contourf function over a somewhat projection with the code:
m_contourf(lon,lat,data(lat,lon),[-20.5:-10.5])
Please take note that I tried restricting the axis limits of the contour i.e. [-20.5:-10.5] as the aim was to get rid of all values above -10.5
Thanks.

Sign in to comment.

 Accepted Answer

Edit the colormap for that figure so that the last value in the matrix is [1 1 1].

8 Comments

Thanks. could you please show how can I edit my code using this colormap function. below is the code.
m_contourf(lon,lat,data(lat,lon),[-20.5:-10.5])
My pleasure.
I don’t have your data, so here is an example contourf plot demonstrating the idea. The highest value of the colour is set at white in the second subplot:
figure(1)
subplot(2,1,1)
contourf(magic(5))
colormap(gca, parula(4))
subplot(2,1,2)
contourf(magic(5))
cm = colormap(parula(4));
cm(end,:) = [1 1 1];
colormap(gca, cm)
Great. Thanks very much for the help. let me try to apply it on my data.
Good day. I seem to have a problem once more with controlling the ticks for the values on the colorbar of the attached figure. is there any way in which i can make them not to overlap.
the code that i used was as follows
m_contourf(lon,lat,data(:,:),[-80:10:80],'linestyle','none'); cm = colormap(gca,(parula(6))); colorbar
I don’t understand what you mean by ‘overlap’. The default behaviour of the ticks are to be in the centres of the colours they depict on the plot, which is how I would expect them to be labeled. Positioning them to be anywhere else would be difficult.
You can manually set the 'Tick' values and 'Ticklabels' as described in Specify Colorbar Ticks and Tick Labels. You can find out what the current colorbar ticks are with the ‘cbt’ assignment, then create a new vector for them with ‘tks’:
cb = colorbar;
cbt = get(cb, 'Ticks');
tks = linspace(min(cbt), max(cbt), 6);
set(cb, 'Ticks', tks)
This uses get and set, but the same set would work with the syntax in the link I included. You will have to experiment to get the result you want. The code snippet I included here should get you started.
Thank you very much and for your patience. I will try very hard.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 10 Nov 2015

Commented:

on 19 Nov 2015

Community Treasure Hunt

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

Start Hunting!