The color outline is different from pcolor

I use pcolor along with contour lines. However, the meaning of the lines cannot be identified from the graph, as can be seen in the following figure.

[xy data] = peaks(1000); data = data / max(max(data)); colorDepth = 1000; colormap(jet(colorDepth)); hold on; pcolor(x,y,data); shading flat [C,hfigc] = contour(x, y, data,[0:0.1:1]); set(hfigc, ... 'LineWidth',1.0, ... 'Color', [1 1 1]); hold off; hcb = colorbar('location','EastOutside'); 

enter image description here

I would prefer pcolor to be in gray values, and contour lines in colors. However, I also need a legend for contour lines.

EDIT: It works somehow by combining two color maps, but then the color bar shows both, which is not what I want. I would prefer to have a color panel that includes the same contour lines as the graph.

 [xy data] = peaks(1000); data = data - min(min(data)); data = data / max(max(data)); colorDepth = 1000; hold on; caxis([-1 1]); colormap([gray(colorDepth); jet(colorDepth)]); hplot = pcolor(x,y,data); shading flat [C,hfigc] = contour(x, y, data-1,[-1:0.1:0]); set(hfigc, 'LineWidth',1.0); % set(hfigc, 'Color', [1 1 1]); hold off; hcb = colorbar('location','EastOutside'); 

EDIT: Color panel can be adjusted with

 set(hcb, 'Ylim', [0 1]); 

enter image description here

+4
source share
1 answer

In addition to the solution presented already in the question, you can use freezeColors and COLORMAP tools and COLORBAR utilities to change the color map by one digit

 addpath('cm_and_cb_utilities'); addpath('freezeColors'); figure(1); clf; [xy data] = peaks(1000); data = data - min(min(data)); data = data / max(max(data)); colorDepth = 1000; hold on; caxis([0 1]); colormap(jet(colorDepth)); hplot = pcolor(x,y,data); shading flat hcb = colorbar('location','EastOutside'); set(hcb, 'Ylim', [0 1]); cbfreeze; freezeColors; colormap(gray(colorDepth)); [C,hfigc] = contour(x, y, data,[0:0.1:1]); set(hfigc, 'LineWidth',1.0); hold off; 

enter image description here

+4
source

Source: https://habr.com/ru/post/1396574/


All Articles