【问题标题】:Is there a limit to the amount of data you can put in a MATLAB pie/pie3 chart?您可以在 MATLAB pie/pie3 图表中放入的数据量是否有限制?
【发布时间】:2014-09-02 08:01:24
【问题描述】:

对于数据集,我的饼图和 MATLAB 中的 3D 饼图上的所有内容都很流畅,但是,我注意到即使我将此饼图的 21 条数据输入到饼图调用中,但只有17 出现。

PieChartNums = [ Facebook_count, Google_count, YouTube_count, ThePirateBay_count,  StackOverflow_count,  SourceForge_count,  PythonOrg_count,  Reddit_count, KUmail_count, Imgur_count, WOWhead_count, BattleNet_count, Gmail_count, Wired_count, Amazon_count, Twitter_count, IMDB_count, SoundCloud_count, LinkedIn_count, APOD_count, PhysOrg_count];
labels = {'Facebook','Google','YouTube','ThePirateBay','StackOverflow', 'SourceForge', 'Python.org', 'Reddit', 'KU-Email',  'Imgur', 'WOWhead', 'BattleNet', 'Gmail', 'Wired', 'Amazon', 'Twitter', 'IMDB', 'SoundCloud', 'LinkedIn', 'APOD', 'PhysOrg'};
pie3(PieChartNums)
legend(labels,'Location','eastoutside','Orientation','vertical')

这适用于标签和物理图本身。

请原谅百分比簇的格式不好,这只是一个粗略的版本。我尝试了每个方向,甚至在方向之间拆分标签,但没有任何运气。

Quasi-better resolution for Pie Chart -- Imgur Link

【问题讨论】:

  • 如果任何数据为零,这将是预期的行为。

标签: matlab pie-chart graphing


【解决方案1】:

就像 Daniel 所说的那样 - 似乎没有任何关于缺失切片的非负数据。我尝试通过以下初始化重现您的问题,但它导致图表看起来正常:

[ Facebook_count, Google_count, YouTube_count, ThePirateBay_count, ...
  StackOverflow_count,  SourceForge_count,  PythonOrg_count,  Reddit_count, ...
  KUmail_count, Imgur_count, WOWhead_count, BattleNet_count, Gmail_count, ...
  Wired_count, Amazon_count, Twitter_count, IMDB_count, SoundCloud_count, ...
  LinkedIn_count, APOD_count, PhysOrg_count] = deal(0.04);

为了验证这个假设 - 您能否提供您用于图表的数据?绘制图表时是否收到任何警告?


pie.m的代码里面:

if any(nonpositive)
  warning(message('MATLAB:pie:NonPositiveData'));
  x(nonpositive) = [];
end

和:

for i=1:length(x)
  if x(i)<.01,
    txtlabels{i} = '< 1%';
  else
    txtlabels{i} = sprintf('%d%%',round(x(i)*100));
  end
end

您可以看到 MATLAB 不会删除有效切片,而只会在数据值较小时重命名它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 1970-01-01
    • 2011-08-21
    相关资源
    最近更新 更多