Image-Process [MATLAB] Changing colors in 3D Graphs

[MATLAB] Changing colors in 3D Graphs

가끔 Figure에 이미지 혹은 Plot 데이터를 서로 다른 Colormap 을이용하여 분석할때 유용한 Coloramp 사용 방법이다.

z=5*sin(x).*cos(y);
ax1=subplot(2,2,1);
    mesh(x,y,z)
    colormap(ax1,parula)
    title('Default colormap(parula)')
ax2=subplot(2,2,2);
    mesh(x,y,z)
    colormap(ax2,jet)
    title('Colormap(jet)')
ax3=subplot(2,2,3);
    colormap(ax3,bone)
    mesh(x,y,z)
    title('Colormap(bone)')
ax4=subplot(2,2,4);
    colormap(ax4,summer)
    mesh(x,y,z)
    title('Colormap(summer)')
figure; set(gcf,'color',[1 1 1])

% image, colormap JET
subplot(3,2,1); imagesc(peaks); axis xy; colormap jet; title('imagesc, jet');
    freezeColors            %freeze colors of current plot
    colorbar; cbfreeze      %how to freeze a colorbar

% same image, using colormap HOT
subplot(3,2,2); imagesc(peaks); axis xy; title('imagesc, hot');
    colormap hot            %now, changing the colormap affects ONLY the current axis!
    freezeColors
    colorbar; cbfreeze

% surface
subplot(3,2,3); surf(peaks); shading interp; colormap hsv; title('surf, hsv');
    freezeColors; colorbar; cbfreeze

% lighted surface, with hole showing nan transparency is preserved after freezing
pnan = peaks; pnan(4:8,end-7:end-3) = nan; % make a small transparent patch
subplot(3,2,4); surfl(pnan); shading interp; colormap hot; title('surfl with NaNs, hot');
    freezeColors; colorbar; cbfreeze

% scatter plot and bar plot
subplot(3,2,5); scatter(randn(100,1),randn(100,1),rand(100,1)*100,rand(100,1),'filled');
    title('scatter, cool'); colormap cool; axis(3*[-1 1 -1 1]);
    freezeColors; colorbar; cbfreeze

subplot(3,2,6); bar(randn(4,3));xlim([0 5]);title('bar, copper'); colormap copper;
    freezeColors;

Leave a Reply

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Related Post

[MATLAB] MATLAB Theme 적용[MATLAB] MATLAB Theme 적용

다른 개발 툴 환경에서는 Dakrular 버전이나 다른 테마적용이 기본적으로 제공이 되며 적용이 쉬운편이다. 하지만 아무리 해도 매트랩환경은 익숙해지지 않아 눈이라도 편하기위해 테마적용하는법을 공유하고자 한다. https://github.com/scottclowe/matlab-schemerscottclowe/matlab-schemerApply and save color schemes in

[MATLAB] MATLAB Runtime[MATLAB] MATLAB Runtime

매트랩 소스코드를 실행파일로 만들어서 실행할 경우 매트랩이 설치되어 있지 않을경우 실행파일이 실행되지 않는 문제점이 있다. 따라서 매트랩이 설치되어 있지 않으면 위와같은 문제점이 일어나는데 매트랩 공식홈페이지에서 제공하는 RUNTIME을 설치하면 쉽게 문제를