matlab便便,豆粑粑 散点密度 热图 等高线图

clear all

clc

clf

%% %%%%%%%%%%%%%%%%%%%%%%%%%

% outline

% plot point density

%

% 01.load points ---------------------------------

% 02.calculate density ---------------------------

% 03.post process --------------------------------

% 04.output --------------------------------------

%% main

%

% 01.load points ---------------------------------

x=load('../data/x.txt');

x(:,1)=[];

y=load('../data/y.txt');

y(:,1)=[];

p=[x';y']';

% 02.calculate density ---------------------------

x_min=0;x_max=25;n_p_x=200;

y_min=1.5;y_max=4.5;n_p_y=201;

x_edge = linspace(x_min,x_max,n_p_x);

y_edge = linspace(y_min,y_max,n_p_y);

[X_edge,Y_edge]=meshgrid(x_edge,y_edge);

ctrs{1}=x_edge;

ctrs{2}=y_edge;

hist_mat = hist3(p,'ctrs',ctrs);

% 03.post process --------------------------------

hist_mat = smooth2(hist_mat,3,3);

hist_mat = hist_mat./sum(hist_mat(:));

% hist_mat = -log(hist_mat);

% tm = hist_mat(~isinf(hist_mat));

% hist_mat(isinf(hist_mat))=max(tm);

% shift_min = min(hist_mat(:));

% hist_mat= hist_mat-shift_min;

% 04.output var -----------------------------------

xx = X_edge;

yy = Y_edge;

zz = hist_mat';

% prob version

% zz = zz./sum(zz(:));

sbp_width=0.7;

sbp_heig=0.8;

n_row = 1;

n_col = 1;

[out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);

h=figure(1)

set(h, 'Position', [1000, 100, 600, 400]);

ax=axes('position',out_pos(1,:));

hold on

n_line=20;

% delete very small value

zz(zz<10^(-5))=nan;

contourf(xx,yy,zz,n_line,'edgecolor','none')

hidden off

shading interp

grid on

box on

colormap(flipud(jet))

xlabel('I am x')

ylabel('I am y')

hb=colorbar;

hb_ytick=hb.Ticks;

percentsy = repmat('%8.3p', length(hb_ytick),1);

for i = 1: length(hb_ytick)

yt=hb_ytick(i);

hb_yticklabel{i}=[num2str(100*yt),'%'];

end

set(hb,'Ticklabels',hb_yticklabel);

ylabel(hb,'percentages')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值