受到您方法的启发,在我的应用中我找到了其他两条线的坐标,而且实现了把线的长度变短的做法,这里附上一个例子,长度变成了原来的0.5倍。
clear;clc;close all;
x = linspace(0,100,1000);
y1 = x;
y2 = x.^2;
y3 = x.^3;
loglog(x,y1,’r’);
hold on;
loglog(x,y2,’b’);
loglog(x,y3,’g’);
[h_legend ,object_h,plot_h,text_strings] = legend({‘a’,’b’,’c’},’Location’,’North’);
hh = findobj(‘type’,’line’)
xxx1 = get(hh(1),’XData’);
xxx2 = get(hh(2),’XData’);
xxx3 = get(hh(3),’XData’);
xxx4 = get(hh(4),’XData’);
xxx5 = get(hh(5),’XData’);
xxx6 = get(hh(6),’XData’);
xxx7 = get(hh(7),’XData’);
xxx8 = get(hh(8),’XData’);
xxx9 = get(hh(9),’XData’);
length(xxx1)
length(xxx2)
length(xxx3)
length(xxx4)
length(xxx5)
length(xxx6)
length(xxx7)
length(xxx8)
length(xxx9)
xxx2(1) = xxx2(1)+(xxx2(2)-xxx2(1))/2; %%起始点向前走0.5个原来的长度。。
set(hh(2),’XData’,xxx2)
set(hh(4),’XData’,xxx2)
set(hh(6),’XData’,xxx2)
legend(‘boxoff’)