MATLAB 颜色图函数(imagesc/scatter/polarPcolor/pcolor)
2维的热度图 imagesc
imagesc(x, y, z),x和y分别是横纵坐标,z为值,表示颜色
imagesc(theta,phi,slc); colorbar
xlabel('theta(°)','fontname','Times New Roman','FontSize',);
ylabel('phi(°)','fontname','Times New Roman','FontSize',);
sta = '3 objects at (θ,φ,r) : (-30,30,1) (0,0,2) (60,-60,0.5)';
str=sprintf(strcat('3D Imaging Slice at :', num2str(d_max*D/N), '(m)', '\n',sta));
title(str, 'fontname','Times New Roman','Color','k','FontSize',);
grid on

其中,colorbar的坐标值调整:caxis([0 1]);
colormap的色系调整:colormap hot
3维散点图 scatter
scatter3(x,y,z,,c,'filled');
% axis([-(R+) (R+) -(R+) (R+) (h+)]);
colorbar

2维 极坐标热度图 polarPcolor
polarPcolor(R_axis, theta, value),前两个为半径方向坐标轴和圆心角坐标轴,value为值,用颜色表示
[fig, clr] = polarPcolor(R_axis, theta, x_d_th, 'labelR','range (m)','Ncircles', ,'Nspokes',);
colormap hot
% caxis([ ]);

其中polarPcolor代码如下:
function [varargout] = polarPcolor(R,theta,Z,varargin)
% [h,c] = polarPcolor1(R,theta,Z,varargin) is a pseudocolor plot of matrix
% Z for a vector radius R and a vector angle theta.
% The elements of Z specify the color in each cell of the
% plot. The goal is to apply pcolor function with a polar grid, which
% provides a better visualization than a cartesian grid.
%
%% Syntax
%
% [h,c] = polarPcolor(R,theta,Z)
% [h,c] = polarPcolor(R,theta,Z,'Ncircles',)
% [h,c] = polarPcolor(R,theta,Z,'Nspokes',)
% [h,c] = polarPcolor(R,theta,Z,'Nspokes',,'colBar',)
% [h,c] = polarPcolor(R,theta,Z,'Nspokes',,'labelR','r (km)')
%
% INPUT
% * R :
% - type: float
% - size: [ x Nrr ] where Nrr = numel(R).
% - dimension: radial distance.
% * theta :
% - type: float
% - size: [ x Ntheta ] where Ntheta = numel(theta).
% - dimension: azimuth or elevation angle (deg).
% - N.B.: The zero is defined with respect to the North.
% * Z :
% - type: float
% - size: [Ntheta x Nrr]
% - dimension: user's defined .
% * varargin:
% - Ncircles: number of circles for the grid definition.
% - Nspokes: number of spokes for the grid definition.
% - colBar: display the colorbar or not.
% - labelR: legend for R.
%
%
% OUTPUT
% h: returns a handle to a SURFACE object.
% c: returns a handle to a COLORBAR object.
%
%% Examples
% R = linspace(,,);
% theta = linspace(,,);
% Z = linspace(,,)'*linspace(0,10,100);
% figure
% polarPcolor(R,theta,Z,'Ncircles',)
%
%% Author
% Etienne Cheynet, University of Stavanger, Norway. //
% see also pcolor
% %% InputParseer
p = inputParser();
p.CaseSensitive = false;
p.addOptional('Ncircles',);
p.addOptional('Nspokes',);
p.addOptional('labelR','');
p.addOptional('colBar',);
p.parse(varargin{:}); Ncircles = p.Results.Ncircles ;
Nspokes = p.Results.Nspokes ;
labelR = p.Results.labelR ;
colBar = p.Results.colBar ;
%% Preliminary checks
% case where dimension is reversed
Nrr = numel(R);
Noo = numel(theta);
if isequal(size(Z),[Noo,Nrr]),
Z=Z';
end % case where dimension of Z is not compatible with theta and R
if ~isequal(size(Z),[Nrr,Noo])
fprintf('\n')
fprintf([ 'Size of Z is : [',num2str(size(Z)),'] \n']);
fprintf([ 'Size of R is : [',num2str(size(R)),'] \n']);
fprintf([ 'Size of theta is : [',num2str(size(theta)),'] \n\n']);
error(' dimension of Z does not agree with dimension of R and Theta')
end
%% data plot
rMin = min(R);
rMax = max(R);
thetaMin=min(theta);
thetaMax =max(theta);
% Definition of the mesh
Rrange = rMax - rMin; % get the range for the radius
rNorm = R/Rrange; %normalized radius [,]
% get hold state
cax = newplot;
% transform data in polar coordinates to Cartesian coordinates.
YY = (rNorm)'*cosd(theta);
XX = (rNorm)'*sind(theta);
% plot data on top of grid
h = pcolor(XX,YY,Z,'parent',cax);
shading flat
set(cax,'dataaspectratio',[ ]);axis off;
if ~ishold(cax);
% make a radial grid
hold(cax,'on')
% Draw circles and spokes
createSpokes(thetaMin,thetaMax,Ncircles,Nspokes);
createCircles(rMin,rMax,thetaMin,thetaMax,Ncircles,Nspokes)
end %% PLot colorbar if specified
if colBar==,
c =colorbar('location','WestOutside');
caxis([quantile(Z(:),0.01),quantile(Z(:),0.99)])
else
c = [];
end %% Outputs
nargoutchk(,)
if nargout==,
varargout{}=h;
elseif nargout==,
varargout{}=h;
varargout{}=c;
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Nested functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function createSpokes(thetaMin,thetaMax,Ncircles,Nspokes) circleMesh = linspace(rMin,rMax,Ncircles);
spokeMesh = linspace(thetaMin,thetaMax,Nspokes);
contour = abs((circleMesh - circleMesh())/Rrange+R()/Rrange);
cost = cosd(-spokeMesh); % the zero angle is aligned with North
sint = sind(-spokeMesh); % the zero angle is aligned with North
for kk = :Nspokes
plot(cost(kk)*contour,sint(kk)*contour,'k:',...
'handlevisibility','off');
% plot graduations of angles
% avoid superimposition of and
if and(thetaMin==,thetaMax == ),
if spokeMesh(kk)<, text(1.05.*contour(end).*cost(kk),...
1.05.*contour(end).*sint(kk),...
[num2str(spokeMesh(kk),),char()],...
'horiz', 'center', 'vert', 'middle');
end
else
text(1.05.*contour(end).*cost(kk),...
1.05.*contour(end).*sint(kk),...
[num2str(spokeMesh(kk),),char()],...
'horiz', 'center', 'vert', 'middle');
end end
end
function createCircles(rMin,rMax,thetaMin,thetaMax,Ncircles,Nspokes) % define the grid in polar coordinates
angleGrid = linspace(-thetaMin,-thetaMax,);
xGrid = cosd(angleGrid);
yGrid = sind(angleGrid);
circleMesh = linspace(rMin,rMax,Ncircles);
spokeMesh = linspace(thetaMin,thetaMax,Nspokes);
contour = abs((circleMesh - circleMesh())/Rrange+R()/Rrange);
% plot circles
for kk=:length(contour)
plot(xGrid*contour(kk), yGrid*contour(kk),'k:');
end
% radius tick label
for kk=:Ncircles position = 0.51.*(spokeMesh(min(Nspokes,round(Ncircles/)))+...
spokeMesh(min(Nspokes,+round(Ncircles/)))); if abs(round(position)) ==,
% radial graduations
text((contour(kk)).*cosd(-position),...
(0.1+contour(kk)).*sind(-position),...
num2str(circleMesh(kk),),'verticalalignment','BaseLine',...
'horizontalAlignment', 'center',...
'handlevisibility','off','parent',cax); % annotate spokes
text(contour(end).*0.6.*cosd(-position),...
0.07+contour(end).*0.6.*sind(-position),...
[labelR],'verticalalignment','bottom',...
'horizontalAlignment', 'right',...
'handlevisibility','off','parent',cax);
else
% radial graduations
text((contour(kk)).*cosd(-position),...
(contour(kk)).*sind(-position),...
num2str(circleMesh(kk),),'verticalalignment','BaseLine',...
'horizontalAlignment', 'right',...
'handlevisibility','off','parent',cax); % annotate spokes
text(contour(end).*0.6.*cosd(-position),...
contour(end).*0.6.*sind(-position),...
[labelR],'verticalalignment','bottom',...
'horizontalAlignment', 'right',...
'handlevisibility','off','parent',cax);
end
end end
end
再贴一个示例代码:
%% Examples
% The following examples illustrate the application of the function
% polarPcolor
clearvars;close all;clc; %% Minimalist example
% Assuming that a remote sensor is measuring the wind field for a radial
% distance ranging from to m. The scanning azimuth is oriented from
% North ( deg) to North-North-East ( deg):
R = linspace(,,)./; % (distance in km)
Az = linspace(,,); % in degrees
[~,~,windSpeed] = peaks(); % radial wind speed
figure()
[h,c]=polarPcolor(R,Az,windSpeed); %% Example with options
% We want to have circles and spokes, and to give a label to the
% radial coordinate figure()
[~,c]=polarPcolor(R,Az,windSpeed,'labelR','r (km)','Ncircles',,'Nspokes',);
ylabel(c,' radial wind speed (m/s)');
set(gcf,'color','w')
%% Dealing with outliers
% We introduce outliers in the wind velocity data. These outliers
% are represented as wind speed sample with a value of m/s. These
% corresponds to unrealistic data that need to be ignored. To avoid bad
% scaling of the colorbar, the function polarPcolor uses the function caxis
% combined to the function quantile to keep the colorbar properly scaled:
% caxis([quantile(Z(:),0.01),quantile(Z(:),0.99)]) windSpeed(::end,::end)=; figure()
[~,c]=polarPcolor(R,Az,windSpeed);
ylabel(c,' radial wind speed (m/s)');
set(gcf,'color','w') %% polarPcolor without colorbar
% The colorbar is activated by default. It is possible to remove it by
% using the option 'colBar'. When the colorbar is desactivated, the
% outliers are not "removed" and bad scaling is clearly visible: figure()
polarPcolor(R,Az,windSpeed,'colBar',) ; %% Different geometry
N = ;
R = linspace(,,N)./; % (distance in km)
Az = linspace(,,N); % in degrees
[~,~,windSpeed] = peaks(N); % radial wind speed
figure()
[~,c]= polarPcolor(R,Az,windSpeed);
ylabel(c,' radial wind speed (m/s)');
set(gcf,'color','w')
%% Different geometry
N = ;
R = linspace(,,N)./; % (distance in km)
Az = linspace(,,N); % in degrees
[~,~,windSpeed] = peaks(N); % radial wind speed
figure()
[~,c]= polarPcolor(R,Az,windSpeed,'Ncircles',);
location = 'NorthOutside';
ylabel(c,' radial wind speed (m/s)');
set(c,'location',location);
set(gcf,'color','w')
MATLAB 颜色图函数(imagesc/scatter/polarPcolor/pcolor)的更多相关文章
- matlab读图函数
最基本的读图函数:imread imread函数的语法并不难,I=imread('D:\fyc-00_1-005.png');其中括号内写图片所在的完整路径(注意路径要用单引号括起来).I代表这个图片 ...
- Matlab脚本和函数
脚本和函数 脚本: 特点:按照文件中所输入的指令执行,一段matlab指令集合.运行后,运算过程产生的所有变量保存在基本工作区.可以进行图形输出,如plot()函数. 举例: 脚本文件ex4_15.m ...
- matlab中patch函数的用法
http://blog.sina.com.cn/s/blog_707b64550100z1nz.html matlab中patch函数的用法——emily (2011-11-18 17:20:33) ...
- 【原创】Matlab.NET混合编程技巧之直接调用Matlab内置函数
本博客所有文章分类的总目录:[总目录]本博客博文总目录-实时更新 Matlab和C#混合编程文章目录 :[目录]Matlab和C#混合编程文章目录 在我的上一篇文章[ ...
- matlab画图形函数 semilogx
matlab画图形函数 semilogx loglog 主要是学习semilogx函数,其中常用的是semilogy函数,即后标为x的是在x轴取对数,为y的是y轴坐标取对数.loglog是x y轴都取 ...
- matlab中subplot函数的功能
转载自http://wenku.baidu.com/link?url=UkbSbQd3cxpT7sFrDw7_BO8zJDCUvPKrmsrbITk-7n7fP8g0Vhvq3QTC0DrwwrXfa ...
- 【原创】Matlab中plot函数全功能解析
[原创]Matlab中plot函数全功能解析 该帖由Matlab技术论(http://www.matlabsky.com)坛原创,更多精彩内容参见http://www.matlabsky.com 功能 ...
- Matlab.NET混合编程技巧之——直接调用Matlab内置函数(附源码)
原文:[原创]Matlab.NET混合编程技巧之--直接调用Matlab内置函数(附源码) 在我的上一篇文章[原创]Matlab.NET混编技巧之——找出Matlab内置函数中,已经大概的介绍了mat ...
- Matlab中plot函数全功能解析
Matlab中plot函数全功能解析 功能 二维曲线绘图 语法 plot(Y)plot(X1,Y1,...)plot(X1,Y1,LineSpec,...)plot(...,'PropertyName ...
随机推荐
- python设置检查点简单实现
说检查点,其实就是对过去历史的记录,可以认为是log.不过这里进行了简化.举例来说,我现在又一段文本.文本里放有一堆堆的链接地址.我现在的任务是下载那些地址中的内容.另外因为网络的问题或者网站的问题, ...
- Hi3518_SDK
第一章 Hi3518_SDK_Vx.x.x.x版本升级操作说明 如果您是首次安装本SDK,请直接参看第2章. 第二章 首次安装SDK 1.Hi3518 SDK包位置 在"Hi3518_V10 ...
- memcached单点登录配置
域名 www.lxy.comblog.lxy.comnews.lxy.comshop.lxy.com php配置 session.save_handler = memcache session写mem ...
- 曹工说Spring Boot源码(21)-- 为了让大家理解Spring Aop利器ProxyFactory,我已经拼了
写在前面的话 相关背景及资源: 曹工说Spring Boot源码(1)-- Bean Definition到底是什么,附spring思维导图分享 曹工说Spring Boot源码(2)-- Bean ...
- list转map,set,使用stream进行转化
#list转map,set,使用stream进行转化 函数式编程: 场景: 从数据库中取出来的数据,经常是list集合类型,但是list转map这种场景虽然不常见,但是有时候也会遇到,最常见的还是转为 ...
- 初识 jquery.simulate.js 模拟键盘事件
用jquery 和 jquery.simulate.js 实现模拟键盘事件,点击上下左右div相当于点击键盘的上下左右键 <!DOCTYPE html> <html> < ...
- Web网页布局的主要方式
一.静态布局(static layout) 即传统Web设计,网页上的所有元素的尺寸一律使用px作为单位. 1.布局特点 不管浏览器尺寸具体是多少,网页布局始终按照最初写代码时的布局来显示.常规的pc ...
- 简单说 用CSS做一个魔方旋转的效果
说明 魔方大家应该是不会陌生的,这次我们来一起用CSS实现一个魔方旋转的特效,先来看看效果图! 解释 我们要做这样的效果,重点在于怎么把6张图片,摆放成魔方的样子,而把它们摆放成魔方的样子,重点在于用 ...
- 【Amaple教程】2. 模块
正如它的名字,模块用于amaplejs单页应用的页面分割,所有的跳转更新和代码编写都是以模块为单位的. 定义一个模块 一个模块由<module>标签对包含,内部分为template模板.J ...
- Django进行数据迁移时,报错:(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1")
进行数据迁移时: 第一步: 命令:python manage.py makemigrations 在对应的应用里面的migrations文件夹中产生了一个0001_initial.py文件 第二步:执 ...