当前位置: 首页 > news >正文

matlab 环形单层柱状图

matlab 环形单层柱状图

matlab 环形单层柱状图
matlab 环形单层柱状图

图片在这里插入图片描述

图片
【图片来源粉丝】
我给他的思路是:直接使用风玫瑰图可以画出。

rose_bar
本次我的更新和这个有些不同!是环形柱状图,可调节细节多;
只需要函数:可实现各个方面:
欢迎持续投稿,宣传自己的工作(不限代码论文等方面)!
rose_bar
使用简单:

输入数据和参数

[ph,fs] =rose_bar(datax,datay,r,R,bw1,xtickvalue);
% note: datax is x;
% datay is y;
% r is inner circle
% R is circle
% bw1 is width of bar,from 2 to inf; 2 is full; increase then thin bar;    %
% ph can control line of circle;;
% fs can control line and face color of bar

先看些结果:在解释如何做出:

默认图,所有颜色一致:
图片在这里插入图片描述

可使用代码调节某一个柱状图的颜色:
例如第十四(14)个为蓝色:
set(fs(14),‘FaceColor’,‘b’,‘EdgeColor’,‘b’)
图片在这里插入图片描述

可调节每一个颜色都不同:
图片在这里插入图片描述

可控制中心⚪的大小
⚪为零:在这里插入图片描述

图片

⚪为大:
图片在这里插入图片描述

可以加单位:一个或多个或全部
图片
可以什么都不要
图片在这里插入图片描述

可以更改xtick
图片

总而言之,挺强的!

主程序:

.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }
clear;clc;close all;
% 构造数据
year = 1:14;
windspeed = 1:14;
yeartick = 2001:2014;
% yeartick = 1:14;
%
close all;
figure
set(gcf,'position',[50 50 850 850 ],'color','w')
% 使用函数
datax = year;
datay = windspeed;
r = 1;
R = 2;
bw1 = 2;
xtickvalue = yeartick;
[ph,fs] =rose_bar(datax,datay,r,R,bw1,xtickvalue);
% set(fs(14),'FaceColor','b','EdgeColor','b')
% 颜色包
load('GMT_drywet.mat')
cmap =GMT_drywet(1:floor(59/length(windspeed)):end,:);
cmap = load('colormore_21.txt');
cmap = cmap(1:20:end,:);
for i = 1:length(fs)set(fs(i),'FaceColor',cmap(i,:),'EdgeColor',cmap(i,:));
end
% note: datax is x;
% datay is y;
% r is inner circle
% R is circle
% bw1 is width of bar,from 2 to inf; 2 is full; increase then thin bar;    %
% ph can control line of circle;;
% fs can control line and face color of bar
title('环形柱状图','FontSize',12,'FontWeight','bold','FontName','time News roman','color',[0.54588199	0.40039200	0.17607801]);
export_fig('环形柱状图.jpg')函数:
.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }
function [ph,fs] = rose_bar(datax,datay,r,R,bw1,xtickvalue)
% note: datax is x;
% datay is y;
% r is inner circle
% R is circle
% bw1 is width of bar
% 数据传入
year = datax;
windspeed = datay;
R = R;
bw1 = bw1;% bw1 最小值 min value is 2; max is not limit;
r = r;
t = 0:0.01:2*pi;
windspeed = windspeed+r;
% 基底
% h(1)=plot(r*sin(t),r*cos(t),'color','k');
if R>=rxlim([-(max(windspeed)+R) max(windspeed)+R])ylim([-(max(windspeed)+R) max(windspeed)+R])
elsexlim([-(max(windspeed)+r) max(windspeed)+r])ylim([-(max(windspeed)+r) max(windspeed)+r])
end
axis equal
axis off
hold on
t1 = 0:2*pi/(length(year)):2*pi;
% scatter(r*sin(t1),r*cos(t1))
bw = 2*pi/(length(year)-1)/bw1;
for i = 1:length(t1)-1t2 = t1(i)-bw:0.01:t1(i)+bw;% plot(r*sin(t2),r*cos(t2))% hold on% plot(windspeed(i)*sin(t2),windspeed(i)*cos(t2))% hold onX = [r*sin(t2) flip((windspeed(i))*sin(t2)) ];Y = [r*cos(t2) flip((windspeed(i))*cos(t2)) ];fs(i)= fill(X,Y,'r');clear X Yhold onX= mean((windspeed(i))*sin(t2));Y = mean((windspeed(i))*cos(t2));text(X,Y,num2str(xtickvalue(i)),'FontSize',12,'FontWeight','bold','FontName','time News roman','Rotation',90,'color','b')clear X Y
end
hold on
T = 0:0.01:pi/8;% 控制标签的摆放位置
for ii = 1:R:max(windspeed)+Rif (r+ii-1)<=(max(windspeed)+R)ph(ii)=plot((r+(ii-1))*sin(t),(r+(ii-1))*cos(t),'LineStyle','--','Color','k');X = mean((r+(ii-1))*sin(T));Y = mean((r+(ii-1))*cos(T));text(X,Y,num2str(ii-1),'FontSize',12,'FontWeight','bold','FontName','time News roman','color',[0.54588199	0.40039200	0.17607801]);hold onif ii == (r+ii-1)%max(1:R:max(windspeed)+R)text(X,Y,[num2str(ii-1),' m/s'],'FontSize',12,'FontWeight','bold','FontName','time News roman','color',[0.54588199	0.40039200	0.17607801]);elsetext(X,Y,[num2str(ii-1)],'FontSize',12,'FontWeight','bold','FontName','time News roman','color',[0.54588199	0.40039200	0.17607801]);endend
end
赞赏直接公益捐赠!
图片
点分享图片
点收藏图片
点在看图片
点点赞

相关文章:

  • 聊一聊接口自动化测试脚本如何进行维护的?
  • Moldflow模流分析教程
  • 轨道六要素的物理意义与几何表示
  • Win10驱动程序强制签名怎么禁用/开启?
  • IEEE:新进展!AI 模型可以生成 3D 脑部MRI 图像,同时解决数据稀缺和隐私问题
  • 第32讲:卫星遥感与深度学习融合 —— 让地球“读懂”算法的语言
  • 打靶日记 zico2: 1
  • Pandas数据合并与重塑
  • 2025.04.19-阿里淘天春招算法岗笔试-第一题
  • 《Android 应用开发基础教程》——第二章:Activity 与生命周期详解
  • MATLAB 控制系统设计与仿真 - 38
  • ACM ICPC算法基础包括哪几类
  • Git命令归纳
  • 国产之光DeepSeek架构理解与应用分析04
  • 43.[前端开发-JavaScript高级]Day08-ES6-模板字符串-展开运算符-ES7~ES11
  • 免费多平台运行器,手机畅玩经典主机大作
  • 一个改善Entity Framework异常处理和错误信息的开源项目
  • 网络--应用层自定义协议与序列化
  • 捋一遍Leetcode【hot100】的二叉树专题
  • leetcode0113. 路径总和 II - medium
  • 美关税政策冲击本土车企:福特7月涨价,通用汽车盈利预期下调
  • 多地市场监管部门公开征集居民水电气计量不准确、收费不规范问题线索
  • “站在亚洲实现整体振兴的新起点上”——习近平主席对越南、马来西亚、柬埔寨进行国事访问纪实
  • 道客网络陈齐彦:技术无界化,开源让AI变成了“全民食堂”
  • 陈宝良:明清时期少林、武当两派的拳法
  • 工人日报社评:下放职称评审权,推动“以产聚才、以才兴产”