【问题标题】:How to get rid of blue line in regression plot in matlab?如何摆脱matlab回归图中的蓝线?
【发布时间】:2016-08-07 16:59:09
【问题描述】:

我有一个带有蓝色 (lsline) 的回归图,我想消除它,但我不知道如何。

plotregression(y.testTargets, y.outputs)

【问题讨论】:

  • 如果你不想要回归线,为什么不直接打电话给plot(y.testTragets, y.outputs, 'ko')
  • 如果要使用回归图,为什么要删除回归图中的直线?...这就像说您要订购不含奶酪的奶酪汉堡包。那不是芝士汉堡……因此,从这里得出,没有回归线的回归图不是回归图……它只是一个图。只需自己绘制实际点! plot(y.testTargets, y.outputs, 'b.');
  • 我想要图中的 y=x 线,但我不喜欢蓝线。

标签: matlab plot regression


【解决方案1】:

如果您只想删除蓝线,您可以使用findall 检索线对象的句柄,然后使用delete 它。同样根据@rayreng 的反馈,我做了它,以便该行也自动从图例中删除。

r = plotregression(rand(5,1), rand(5,1));

%// Make the legend dynamic before removing the line
legend('-DynamicLegend', 'Location', get(legend, 'Location'));

%// Remove the blue line (with the "Fit" label)
delete(findall(r, 'DisplayName', 'Fit'));

【讨论】:

  • 是否有办法删除该行的图例条目?...只是好奇。这条线被删除了,但表示这条线仍然存在的图例条目仍然存在....尽管我认为这个问题没有意义,但现在这引起了我的兴趣。
  • @rayryeng 已更新。
  • @rayryeng 如果plotregression 命令没有将图例放在左上角,您可以在删除该行之前调用legend('-DynamicLegend')
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多