image thumbnail

freezeColors / unfreezeColors

バージョン 1.3.0.0 (146 KB) 作成者: John Iversen
Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images.

ダウンロード 47.1K 件

更新 2017/1/16

ライセンスの表示

編集メモ: This file was selected as MATLAB Central Pick of the Week

Update: 2017: As of Matlab 2014b, this may no longer be needed as MATLAB now allows multiple colormaps per figure--please see my comment. Thanks!
Version 2.3, 3/2007
(*What's NEW: 9/2010, A colorbar solution)

Problem: There is only one colormap per figure, so all plots share the same colormap. Often one wants different colormaps.

Solution: This function pair provides an easy way to have plots using different colomaps in the same figure.

Example:
subplot(2,1,1)
imagesc(peaks)
colormap hot
freezeColors %freeze this plot's colormap

subplot(2,1,2)
colormap hsv % won't change any frozen plots!
surf(peaks)
freezeColors
etc...

**** COLORBAR WORKAROUND (NEW 9/2010) ****
** Note: in recent versions of MATLAB the colorbar is reinitialized
** whenever you call COLORMAP, which undoes the effects of freezeColors.
**
** Suggested solution: Use the function CBFREEZE, by
** Carlos Adrian Vargas Aguilera, located in the fileexchange
** http://www.mathworks.com/matlabcentral/fileexchange/24371

%usage
h=colorbar; cbfreeze(h), or simply cbfreeze(colorbar)

%Colorbar workaround example
imagesc(peaks)
freezeColors
cbfreeze(colorbar)

Since Carlos has made a nice solution, I have chosen not to duplicate his efforts. Please use his fine code.
****

FUNCTIONS

freezeColors Freeze colors of plots, making them immune to later changes in the colormap. Converts colors of many graphics objects (images, surfaces, scattergroups, bar plots, patches, etc--anything using indexed CData) to [r g b] truecolor.

unfreezeColors Reverses the effects of freezeColors. Restores the original indexed color data, allowing the colormap and caxis to again affect the plots.

Demo & Documentation in freezeColors_pub.html, test in test/test_main.m.

引用

John Iversen (2022). freezeColors / unfreezeColors (https://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2010a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!