Contourf and NaNs (how to make white regions transparent)

前端 未结 2 1512
半阙折子戏
半阙折子戏 2021-02-19 16:19

I\'m trying to make a contourf plot but certain areas of the data array have NaNs (only in the data matrix, the x and y meshgrid matrices are full). I\'d like these

2条回答
  •  死守一世寂寞
    2021-02-19 16:51

    Would it be an option to use pcolor instead of contourf?

    [X Y] = meshgrid(10:50);
    Z = X.*Y;
    Z(10:30,10:30) = NaN;
    figure
    imshow(uint8(repmat(1:4:240,[60,1,3])));
    hold on;
    h = pcolor(X,Y,Z)
    set(h,'Edgecolor',  'interp');
    colormap jet;
    

    enter image description here

提交回复
热议问题