如何使Matlab图例识别多个散点图? [英] How to make a matlab legend recognize multiple scatter plots?

查看:162
本文介绍了如何使Matlab图例识别多个散点图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一图形窗口中放置三个散点图,并有一个描述它们的图例.散点图很好地绘制了同一窗口中的所有负载,但图例仅识别最后一个序列.换句话说,图例为其每个条目显示一个红色标记(最后一个系列的颜色).

I want to place three scatter plots in the same figure window and have a legend that describes them. The scatter plots all load in the same window just fine, but the legend only recognizes the last series. In other words, the legend shows a red marker (the color for the last series) for each of its entries.

如何使图例识别每个散点,而不仅仅是最后一个散点?我尝试了很多不同的方法,但似乎都没有效果.谢谢!

How do I make the legend recognize each scatter and not just the last one? I've tried a bunch of different things, and none of them seem to work. Thanks!

图片是我的一个数据集的图,请注意图例.

The picture is the plot for one of my datasets, note the legend.

s10 = scatter3(x1, y1, z1, 'b'); hold on;
s1 = scatter3(x2, y2, z2, 'g'); hold on;
s01 = scatter3(x3, y3, z3, 'r'); hold on;
legend([s10,s1,s01], {'10ms', '1ms', '0.1ms'}) 
% Every legend entry is red (pertains to the last series)

推荐答案

对我来说,这似乎与Matlab的最新版本(R2015b)相关;在此版本中,我遇到了与您相同的问题,图例条目仅显示一种颜色(与无法重现该问题的其他答案相反).但是,如果我回滚到以前的版本(R2010b),问题就会消失.我不确定您是否可以选择该选项,但这可能有助于诊断出确切的问题.

For me this seems to be associated with the recent version of Matlab (R2015b); in this version I get the same problem as you with the legend entries showing only one color (in contrast to the other answers that can't reproduce the problem). But if I roll back to a previous version (R2010b), the problem goes away. I'm not sure if you have that option, but it might help diagnose the precise issue.

这篇关于如何使Matlab图例识别多个散点图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆