matlab plot 多张图,给大家一个非常好用的matlab程序(一个figure中画多幅图,colormap如何设置)...

这篇博客介绍了一个名为freezeColors的Matlab函数,该函数允许在同一个figure中绘制使用不同colormaps的多幅图,并能锁定图形颜色。通过调用freezeColors,可以确保后续改变colormap不会影响已经绘制的图形颜色。博客还提供了函数的使用方法和示例,包括如何处理不同类型的图形对象,并提到了由于Matlab的限制,colorbars需要使用其他函数cbfreeze来冻结。
摘要由CSDN通过智能技术生成

function freezeColors(varargin)

% freezeColors Lock colors of plot, enabling

multiple colormaps per figure. (v2.3)

%

% Problem: There is only one

colormap per figure. This function provides

% an easy solution when plots using different colomaps are

desired

% in the same figure.

%

% freezeColors freezes the

colors of graphics objects in the current axis so

% that subsequent changes to the colormap (or caxis) will not change

the

% colors of these objects. freezeColors works on any graphics

object

% with CData in indexed-color mode: surfaces, images,

scattergroups,

% bargroups, patches, etc. It works by converting CData to true-color

rgb

% based on the colormap active at the time freezeColors is

called.

%

% The original indexed color

data is saved, and can be restored using

% unfreezeColors, making the plot once again subject to the colormap

and

% caxis.

%

%

% Usage:

% freezeColors applies to all objects in current axis (gca),

% freezeColors(axh) same, but

works on axis axh.

%

% Example:

% subplot(2,1,1); imagesc(X); colormap hot; freezeColors

% subplot(2,1,2); imagesc(Y); colormap hsv; freezeColors etc...

%

% Note: colorbars must also be frozen. Due to Matlab 'improvements'

this can

% no

longer be done with freezeColors. Instead, please

% use

the function CBFREEZE by Carlos Adrian Vargas Aguilera

% that

can be downloaded from the MATLAB File Exchange

% (http://www.mathworks.com/matlabcentral/fileexchange/24371)

%

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

%

% For additional examples, see test/test_main.m

%

% Side effect on render mode:

freezeColors does not work with the painters

% renderer, because Matlab doesn't support rgb color data in

% painters mode. If the current renderer is painters,

freezeColors

% changes it to zbuffer. This may have unexpected effects on other

aspects

% of your plots.

%

% See also unfreezeColors, freezeColors_pub.html, cbfreeze.

%

%

% John Iversen (iversen@nsi.edu) 3/23/05

%

% Changes:

% JRI (iversen@nsi.edu)

4/19/06 Correctly handles

scaled integer cdata

% JRI

9/1/06 should now handle all

objects with cdata: images, surfaces,

% scatterplots. (v 2.1)

% JRI 11/11/06 Preserves NaN

colors. Hidden option (v 2.2, not uploaded)

% JRI 3/17/07 Preserve caxis after freezing--maintains colorbar scale (v<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值