如何在Matlab绘图窗口中自定义图例 [英] How to customize a legend in matlab plot window

查看:935
本文介绍了如何在Matlab绘图窗口中自定义图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下图所示,图例对于绘图窗口而言太长.我想做的是:

As shown in the image below, the legend is too long for the plot window. what I want to do is:

1-要知道如何在第二行中分割图例?

1- To know how to split the legend over a second line?

2-要了解如何缩短图例中指示的红线.如您所见,图例中包含一条红线(x1 = ......),我想知道是否有可能缩短该红线或控制其长度.

2- To know how to shorten the red line in indicated in the legend. As you see, the legend contains a red line then (x1=......), I want to know whether there is any possibility to shorten that red line or to control its length.

推荐答案

关于第二个问题-您可以使用2个输出参数调用图例:

As for you second question - you can call legend with 2 output arguments:

[h,att] = legend('show')

然后使用att.XData属性操作此行.

And then use att.XData property to manipulate this line.

plot(sin(-pi:0.1:pi),'r')
[h,att] = legend('show')
att(2).XData(2) = 0.2;

结果:

这篇关于如何在Matlab绘图窗口中自定义图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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