首页 > 解决方案 > matlab多维图例可能吗?

问题描述

我有一些绘图代码,我想在其中绘制 10 种不同类型的数据点。我想使用 5 种颜色和 2 个符号。

基本上,如果我的表条目的行或列包含一个包含子字符串“CSC”的字符串,我想更改使用的标记。c 设置在此循环之外并控制符号的颜色。

如何显示一个图例,显示我的颜色列表及其相关值,以及符号及其值。以文本形式,图例将是,例如:

Colours:
red = One noun
green = a second noun
yellow = another noun
Symbols:
+ = isn't in a row or column that has an entry containing "CSC"
o = is in a row or column with an entry containing "CSC

下面是我的代码片段...

for k_ind = 1:length(keepers)
            row = T.Row(keepers(k_ind));
            column = T.Col(keepers(k_ind));

            %Does this row or column contain a 'CSC'?
            if(any(contains(string(T{T.Row==row,'cell_cond'}), 'CSC')) || any(contains(string(T{T.Col==column,'cell_cond'}), 'CSC')) )
                symbol = 'o';
                plot(T.total_read_pairs(keepers(k_ind)), max(T.only_matched_arabidopsis(keepers(k_ind)),0.001), symbol, 'color', C(c,:), 'markersize', 12, 'linewidth', 2)
            else
                symbol = '+';
                plot(T.total_read_pairs(keepers(k_ind)), max(T.only_matched_arabidopsis(keepers(k_ind)),0.001), symbol, 'color', C(c,:), 'markersize', 12, 'linewidth', 2)
            end
        end
end

#Draw the legend down here
legend(...)

标签: matlablegend

解决方案


推荐阅读