Color Palette Tables (.cpt) for Matlab

버전 1.7.0.1 (1.07 MB) 작성자: Kelly Kearney
Create and apply GMT-style colormaps in Matlab
다운로드 수: 7.3K
업데이트 날짜: 2021/9/23

cptcmap.m Documentation

Author: Kelly Kearney View Color Palette Tables (.cpt) for Matlab on File Exchange

This function creates and applies a colormap defined in a color palette table (.cpt file). Color palette files provide more flexible colormapping than Matlab's default schemes, including both discrete and continuous gradients, as well as easier direct color mapping.

For a full description of the cpt file format, see the Generic Mapping Tools documentation (https://www.generic-mapping-tools.org).

This package includes 20 standard GMT colormaps; please see the header of each file for copyright information. Many more color tables are available on the cpt-city website (http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html).

Syntax

cptcmap(name);
cptcmap(name, ax);
cptcmap(... param, val, ...);
[cmap, lims, ticks, bfncol, ctable] = cptcmap(...)

h = cptcbar(ax, map, loc, flag)

See function help for full description of input and output variables

Example

We'll start with a simple pcolor plot of topography.

[lat, lon, z] = satbath(10);

axes('position', [0.05 0.15 0.9 0.7]);
pcolor(lon, lat, z);
shading flat;

cb = colorbar;

cptcmap1

Apply the GMT_globe.cpt color palette table. The color limits of this table are set to match global topography, so we'll use direct mapping here.

cptcmap('GMT_globe', 'mapping', 'direct');

cptcmap2

If you want to label the specific color intervals used in the colormap, replace the colorbar with a cptcbar (which mimics a colorbar).

delete(cb);
cb = cptcbar(gca, 'GMT_globe', 'eastoutside', false);
set(cb.ax, 'fontsize', 7);

cptcmap3

Sometimes, it's useful to show even color intervals on the colorbar, even if the tick values are unevenly spaced. In this example, the near-sea-level tick labels get too squished to read. Use the last input of cptcbar to change this.

delete(cb.ax);
cb = cptcbar(gca, 'GMT_globe', 'eastoutside', true);
set(cb.ax, 'fontsize', 7);

cptcmap4

인용 양식

Kelly Kearney (2024). Color Palette Tables (.cpt) for Matlab (https://github.com/kakearney/cptcmap-pkg), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2010a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

cptcmap

minmax

parsepv

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.7.0.1

linked GitHub readme

1.7.0.0

- Linked to GitHub repository
- Added cptcbar.m to create colorbars
- Now allows for multiple folders holding .cpt files

1.6.0.0

Corrected bug in colormap length calculation

1.5.0.0

- Corrected bug in HSV color calculation
- Updated for 2014b graphics

1.4.0.0

Added error check in case no input is supplied. Also corrected the roundn issue (correctly, this time).

1.3.0.0

Replaced roundn call with manual calculation to remove unintended dependency on Mapping Toolbox.

1.2.0.0

-bug fixes where some input filenames were misinterpreted (thanks to Felipe)
-colormap display option no longer relies on external functions, has cleaner display, and renders more quickly

1.0.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.