【问题标题】:matlab. labels to a pie chartMATLAB。饼图的标签
【发布时间】:2014-10-15 00:20:20
【问题描述】:

我有一个矩阵 X。在第一列中有 5 个值,它们是从 0 到 4 的整数。在第二列中,有我想在饼图中绘制的值。如何在饼图中用 X(:,1) 中的相应值标记 X(:,2) 中的值?

【问题讨论】:

    标签: matlab plot pie-chart


    【解决方案1】:

    据我了解,这可能会奏效:

    clear all
    clc
    
    A = [0 3;1 1;2 5;3 6;4 5]; %// Generate dummy data
    
    Labels = sprintfc('Row%d',A(:,1)+1) %// Generate appropriate labels and store in a cell array
    

    标签如下所示:

    Labels = 
    
        'Row1'
        'Row2'
        'Row3'
        'Row4'
        'Row5'
    

    还有饼图:

    pie(A(:,2),Labels)
    

    这是你的意思吗?您可能想查看here,了解有关饼图和自定义标签方式的更多信息。例如sprintf 可用于生成更复杂的标签。如果你想知道怎么做,请问!

    【讨论】:

    • 嗨@Yulia,这就是你要找的吗?
    猜你喜欢
    • 2014-12-08
    • 2017-12-01
    • 1970-01-01
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多