How do i calibrate multiple sub plots to the same colorbar

조회 수: 3 (최근 30일)
Rascal07
Rascal07 2018년 2월 2일
댓글: Rik 2018년 2월 7일
I am running the simple piece of code below creating a 3 by 3 subplot of a variety seafloor features as pcolor surf plots. I would like to get elevation = 0 to be the same colour in all sub plots and so on for each other elevation allowing one color bar to be used for all 9 plots within the sub plot. Does anyone know how to do this?
ncfile = 'GEBCO_2014_2D_Hawaii.nc' ; % nc file name % To get information about the nc file ncinfo(ncfile) % to display nc file ncdisp(ncfile) % to read a vriable 'var' exisiting in nc file elevation = ncread(ncfile,'elevation') ; lat = ncread(ncfile,'lat') ; lon = ncread(ncfile,'lon') ;
figure (1) subplot(3,3,1) pcolor(-lat,-lon,elevation) shading interp colormap jet colorbar surf(-lat,-lon,elevation) shading interp grid on title('Hawaii') colorbar

채택된 답변

Rik
Rik 2018년 2월 2일
You can't link the colorbar itself. You will have to use the same colormap. If you set the figure as a target for colormap, the property will be inherited by the subplots (you might need to recreate them, I didn't test). This inheritance used to be default behavior, but since a few years back (R2014b) you can have a different colormap for each axis in a figure.
  댓글 수: 2
Rascal07
Rascal07 2018년 2월 7일
Ive used the same colormap (jet) fo the entire figure however in some subplots 0 is reprisented by yellow and in others in red. is the a way to change this?
Rik
Rik 2018년 2월 7일
My guess would be this would be because of different data types (double/single vs (u)int8/16/32/64) indexing in different ways into the colormap, but I haven't tested this.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by