Mathematica中文论坛-非官方
标题:
豆粑粑 matlab polarhistogram 极坐标的bar图
[打印本页]
作者:
meatball1982
时间:
2025-11-11 11:20
标题:
豆粑粑 matlab polarhistogram 极坐标的bar图
给小LY画图,用的是python 实现的,
我想在matlab中也实现一下。
clear all
clc
close all
% clf
theta = [0.1 1.1 5.4 3.4 2.3 4.5 3.2 3.4 5.6 2.3 2.1 3.5 0.6 6.1];
nbins = 6;
thetaBins = linspace(0,2*pi,nbins+1);
counts = histcounts(theta, thetaBins);
figure
tcl = tiledlayout(1,2);
nexttile(tcl)
polarhistogram(theta,nbins)
title('polarhistogram')
pax = polaraxes(tcl);
pax.Layout.Tile = 2;
hold(pax,'on')
% faceColor = turbo(nbins); % choose your face colors
faceColor = jet(nbins);
for i = 1:numel(counts)
polarhistogram(pax,'BinEdges',thetaBins(i:i+1),'BinCounts',counts(i), ...
'FaceColor', faceColor(i,:), ...
'FaceAlpha', 0.3, ... % to match image in OP's question
'EdgeColor','w') % to match image in OP's question
end
title('loop')
h=gcf;
fi_na='./fig_polarhistogram';
fun_work_li_035_myfig_out(h,fi_na,3);
复制代码
fig_polarhistogram.png
(239.69 KB, 下载次数: 108)
下载附件
2025-11-11 11:20 上传
欢迎光临 Mathematica中文论坛-非官方 (http://ilovemathematica.com/)
Powered by Discuz! X3.2