Last active
September 16, 2018 08:53
-
-
Save elenyafea/7b3554156c3f48416a2dfd5aff15dcec to your computer and use it in GitHub Desktop.
matlab 绘制极坐标柱形图
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
在某个点需要表示多维数据时,简单的柱形图很难看,这个时候南丁格尔玫瑰图作用就体现出来了! | |
南丁格尔就是那个伟大的护士,她在做报表时发明的这种图,所以后人以她的名字命名。简单来说我们可以用极坐标下的柱状图来理解。 | |
实现是用polarhistogram函数实现的,本来包含了统计,虽然用在这里有点大材小用,但是没想到其他方法。 | |
提供了两个参数第一个是一维的纵数组,第二个是是否去坐标,0是去坐标,1是保留坐标,默认为1. | |
```matlab | |
function d_nrose(e,bac) | |
if nargin<2 | |
bac=1; | |
end | |
[N,~]=size(e); | |
c=rand(1,N); | |
b=rand(1,N); | |
a=rand(1,N); | |
%配色随机生成,不满意再来一次 | |
for i=1:N | |
ra= 0:2*pi/N:2*pi; | |
ee=zeros(1,N); | |
ee(i)=e(i); | |
%绘制柱状图的一个柱子 | |
polarhistogram('BinEdges',ra,'BinCounts',ee,'FaceColor',[c(i) a(i) b(i)],'FaceAlpha',1,'Edgecolor','none'); | |
hold on; | |
end | |
%是否关闭背景 | |
if bac==0 | |
hold off; | |
ax=gca; | |
ax.Visible='off'; | |
end | |
end | |
``` | |
利用随机数来生成的图片 | |
```matlab | |
e=rand(10,1); | |
d_nrose(e); | |
``` | |
 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment