Mathematica中文论坛-非官方

标题: 豆粑粑 matlab polarhistogram 极坐标的bar图 [打印本页]

作者: meatball1982    时间: 2025-11-11 11:20
标题: 豆粑粑 matlab polarhistogram 极坐标的bar图
给小LY画图,用的是python 实现的,
我想在matlab中也实现一下。

  1. clear all
  2. clc
  3. close all
  4. % clf

  5. 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];
  6. nbins = 6;
  7. thetaBins = linspace(0,2*pi,nbins+1);
  8. counts = histcounts(theta, thetaBins);
  9. figure
  10. tcl = tiledlayout(1,2);
  11. nexttile(tcl)
  12. polarhistogram(theta,nbins)
  13. title('polarhistogram')
  14. pax = polaraxes(tcl);
  15. pax.Layout.Tile = 2;
  16. hold(pax,'on')
  17. % faceColor = turbo(nbins);  % choose your face colors
  18. faceColor = jet(nbins);
  19. for i = 1:numel(counts)
  20.     polarhistogram(pax,'BinEdges',thetaBins(i:i+1),'BinCounts',counts(i), ...
  21.         'FaceColor', faceColor(i,:), ...
  22.         'FaceAlpha', 0.3, ...  % to match image in OP's question
  23.         'EdgeColor','w')     % to match image in OP's question
  24. end
  25. title('loop')

  26. h=gcf;
  27. fi_na='./fig_polarhistogram';
  28. fun_work_li_035_myfig_out(h,fi_na,3);
复制代码


fig_polarhistogram.png (239.69 KB, 下载次数: 108)

fig_polarhistogram.png





欢迎光临 Mathematica中文论坛-非官方 (http://ilovemathematica.com/) Powered by Discuz! X3.2