本帖最后由 dingding 于 2013-4-30 22:43 编辑 如题,text命令怎样将标注自动放在空白处,如图所示,是用text(x,y,"string"),写死的,这样的缺点是标注有时候和 K线图重合,不好看。希望能够提供解决方案,不限于text命令,如果是legend或者其他命令可以实现也可以。 本人用的一段代码如下: ds=axis; text(20,(ds(3)+ds(4))/2,['收益率: ',syl],'FontSize',10,'FontWeight','bold','color','k') text(25,ds(3)+(ds(3)+ds(4))/4,['盈亏金额: ',num2str(yingli)],'FontSize',10,'FontWeight','bold','color','k') |
12 条回复
先用高低点坐标凑合用吧,有高人如果有更好的找到空隙的方法,请指教。 text(ind2,amax,['收益率: ',syl],'FontSize',10,'FontWeight','bold','color','k') text(ind1,amin,['盈亏金额: ',num2str(yingli)],'FontSize',10,'FontWeight','bold','color','k') |
把text改为gtext,你可以把你的标注放到任何你想要的位置~~~ |
function location=get_location_from_numeric(n) location = []; % 0 = Automatic "best" placement (least conflict with data) % 1 = Upper right-hand corner (default) % 2 = Upper left-hand corner % 3 = Lower left-hand corner % 4 = Lower right-hand corner % -1 = To the right of the plot switch n case -1 location = 'NorthEastOutside'; case 0 location = 'Best'; case 1 location = 'NorthEast'; case 2 location = 'NorthWest'; case 3 location = 'SouthWest'; case 4 location = 'SouthEast'; end 这是legend中的一段寻找位置的程序 我感觉 text肯定也可以找到空白处,也就是“best",只是我不会做。 |
你可以不显示那么多条K线,右边专门留部分位置出来标志 |
dingding 发表于 2013-5-7 19:14 楼主问题解决了吗 |
Powered by Discuz! X3.4
© 2001-2022