当前位置: 首页 > 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
赞赏直接公益捐赠!
图片
点分享图片
点收藏图片
点在看图片
点点赞
http://www.xdnf.cn/news/32383.html

相关文章:

  • 解锁异步JavaScript性能:从事件循环(Event Loop)到Promise与Async/Await的最佳实践
  • 电商平台计算订单成交额是不是要去除退款退货的
  • CMFA在自动驾驶中的应用案例
  • 多线程使用——线程安全、线程同步
  • 【Canvas与旗帜】标准英国米字旗
  • 实现批量图片文字识别(python+flask+EasyOCR)
  • 系统架构设计师:计算机组成与体系结构(如CPU、存储系统、I/O系统)案例分析与简答题、详细解析与评分要点
  • 【C++动态规划】2801. 统计范围内的步进数字数目|2367
  • 洛谷P1177【模板】排序:十种排序算法全解(2)
  • Docker安装与介绍(一)
  • 【工具变量】A股上市公司信息披露质量KV指数测算数据集(含do代码 1991-2024年)
  • 青少年编程与数学 02-016 Python数据结构与算法 29课题、自然语言处理算法
  • 黑马Java基础笔记-1
  • 计算机网络——常见的网络攻击手段
  • 面试题之如何设计一个秒杀系统?
  • 编程语言基础 - C++ 面试题
  • jenkins尾随命令
  • word选中所有的表格——宏
  • ETF价格相关性计算算法深度分析
  • Java Stream 复杂场景排序与分组技术解析与示例代码
  • 蓝桥杯 蜗牛 动态规划
  • 遨游科普:防爆平板是指什么?有哪些应用场景?
  • 使用vue2技术写了一个纯前端的静态网站商城-鲜花销售商城
  • javassist
  • Python concurrent.futures模块的ProcessPoolExecutor, ThreadPoolExecutor类介绍
  • 在 Node.js 中使用原生 `http` 模块,获取请求的各个部分:**请求行、请求头、请求体、请求路径、查询字符串** 等内容
  • Python爬虫实战:获取网易新闻数据
  • Windows系统安装`face_recognition`
  • 2. ubuntu20.04 和VS Code实现 ros的输出 (C++,Python)
  • DeepSeek与Napkin:信息可视化领域的创新利器