如何在matlab中添加条形图的三个图例?

时间:2015-05-23 13:14:45

标签: matlab plot bar-chart legend precision-recall

我有一个条形图,可以计算三种不同方法的进动和召回,并以三种不同的颜色表示它们,我使用的代码如下

x=[0.4,0.31,0.21]
y=[0.45,0.38,0.27]
bar(x,y,0.1)
h = bar(x,diag(y),0.1,'stacked');
xlabel('precession')
ylabel('recall') 

enter image description here

我想添加一个应显示maroon color is for indiscernible relationgreen is for discernible relationblue is for equivalence relation

的图例

1 个答案:

答案 0 :(得分:2)

试试这个:

    $scope.isInvoiceAmountInvalid = function(){
       var error = $scope.invoiceForm.invoiceAmount.$error;
       var required = error.hasOwnProperty("required") && error.required;
       var pattern = error.hasOwnProperty("pattern") && error.pattern;
       console.log("Inside isInvoiceAmountInvalid", error, required, pattern);

       return (required || pattern);
     };

     $scope.isVatAmountInvalid = function(){
       var error = $scope.invoiceForm.vatAmount.$error;
       var required = error.hasOwnProperty("required") && error.required;
       var pattern = error.hasOwnProperty("pattern") && error.pattern;
       console.log("Inside isVatAmountInvalid", error, required, pattern);

       return (required || pattern);
     };

颜色将自动插入图例