0

Composite FigureI want that each successive contour is plotted with a different color or to use a colormap for the contour plot. Right now all the contours are being plotted in white. I tried to change the color of the contours but all I could do was to color all of them black by using 'k' in the contour() function.

P.S> I'm plotting this over another pcolor() figure (which has a different colormap for itself) using hold on.

Here is some part of the plotting code :

grid_x = 20:0.25:160;
grid_y = 30:-0.25:-10;

grid_x_sph = 20:2.5:160;
grid_y_sph =  30:-2.5:-10;

grid_lon = 20:1:160;
grid_lat = 30:-1:-10;

% grid is my struct containing other structs with data over a region 
    wave_data = grid.olr.avg(1).mjo; 
    sph_data = grid.avg.sph(1).mjo;
    u_data = grid.avg.u(1).mjo;
    v_data = grid.avg.v(1).mjo;



figure(13);
pcolor(grid_x,grid_y,wave_data'); shading interp; colormap(cmap3); hold on; colorbar;
[imxx,c]= contour(grid_x_sph,grid_y_sph,sph_data',8); 
quiver(grid_lon(1:3:end),grid_lat(1:3:end),u_data(1:3:end,1:3:end)',v_data(1:3:end,1:3:end)','k'); hold on;
xlim([20 160]);
ylim([-10 30]);
caxis([-7 5]);
load coast; hold on;
plot(long,lat,'k');
plot(long+360,lat,'k');
ylabel('LATITUDE');
title('MJO');
anish
  • 13
  • 4
  • 2
    I don't really understand the problem you have. Please provide example data and a screenshot of the plot, explaining whats going wrong. – Robert Seifert Apr 06 '20 at 11:06
  • @thewaywewalk I updated the code a bit. and added the figure too. you can give it a look now. – anish Apr 06 '20 at 11:50
  • Can you please make a [mcve], i.e. a piece of code that **we** can run. If you cannot provide the `grid` struct, or at least part of it, try to make something with random data, or built-in functions, in such a way that **we** can run it as well. And what was said before, please add the image to point out why that isn't correct. – Adriaan Apr 06 '20 at 11:53
  • The documentation of [`contour()`](https://mathworks.com/help/matlab/ref/contour.html) suggests that by default the colours of the contours follow the parula colormap. If you get single coloured contours, you probably changed something with respect to that option somewhere. – Adriaan Apr 06 '20 at 11:54
  • I can mail you a .mat file if you want for these variables. @Adriaan – anish Apr 06 '20 at 11:56
  • 1
    No, I don't want an email with the mat file. The problem with that is that only I can help you then, or you'd need to email the data to everyone. This is why everything necessary to solve the problem must be **in the post itself**, such that everyone seeing this can answer it. – Adriaan Apr 06 '20 at 11:57
  • @Adriaan I've my own custom colormap to use for the contours. How do I apply that? Also, I never changed anything w.r.t. the colormap for contour prior to this line of code. – anish Apr 06 '20 at 11:58

0 Answers0