Marker会出现在所有数据点上,不可能控制其间距。
要想不丢失数据而使得Marker稀疏,一种变通的做法是,在原图的基础上另外绘制一条曲线,该曲线专门用于绘制Marker,其数据由原曲线的数据提取。
下面的代码演示了实现方法,但需要注意的是,目前只适合图形中只有一条曲线的情况,如果有多条曲线,还需进行一些修改。
syms xGstar yArstar
D1=1.5; D2=1.6; K=4; phi=0.01;
acstar1 = (0.5*sqrt(pi)*K*phi)^(2/(1-D1))*xGstar^2;
acstar2 = (0.5*sqrt(pi)*K*phi)^(2/(1-D2))*xGstar^2;
h = ezplot(sqrt(xGstar/pi)*(yArstar/3)^0.75*log(yArstar/(3*acstar1))+ ...
K*phi*yArstar^0.75*(3*acstar1)^0.25-3e-4,[1e-9,1e-5,1e-5,5.0e-1]);
set(h,'LineStyle','-','color','k');
X = get(h, 'x');
Y = get(h, 'y');
dX = max(X) - min(X);
dY = max(Y) - min(Y);
e = 0.01; % 距离系数,越小则越密集
clear x y
x(1) = X(1);
y(1) = Y(1);
for i = 2 : length(X)
if sqrt( ((X(i)-x(end))/dX)^2 + ((Y(i)-y(end))/dY)^2 ) >= e
x(end+1) = X(i);
y(end+1) = Y(i);
end
end
% 使用相同的颜色和线宽绘制Marker
hold on
plot(x,y,'o','color',get(h,'color'),'linewidth',get(h,'linewidth'))
改成这样
syms xGstar yArstar
D1=1.5;D2=1.6;K=4;phi=0.01;
acstar1=(0.5*sqrt(pi)*K*phi)^(2/(1-D1))*xGstar^2;
acstar2=(0.5*sqrt(pi)*K*phi)^(2/(1-D2))*xGstar^2;
h=ezplot(sqrt(xGstar/pi)*(yArstar/3)^0.75*log(yArstar/(3*acstar1))+K*phi*yArstar^0.75*(3*acstar1)^0.25-3e-4,[1e-9,1e-5,1e-5,5.0e-1]);
set(h,'LineStyle','-','color','k','Marker','o','MarkerSize',0.02);