by 今天不飞了
每天做实验画图都是点点线线,枯燥乏味,生无可恋,就突发奇想把各种marker改成表情包。不过只适用于数据量较小的,太多就画的很慢了。
b站视频链接把B站表情包植入MATLAB
% x,y 坐标向量
% ltype 线型
% mtype 图标编号
% siz 图标大小
function emoplot(x,y,ltype,mtype,siz)
% 加载表情
load emo
x = x(:);
y = y(:);
rp = rp*siz;
cp = cp*siz;
num = length(x);
% 绘制
plot3(x,y,zeros(size(x)),ltype,'LineWidth',5),hold on
for n = 1:num
h = surf(cp+x(n),rp+y(n),hp,'EdgeAlpha',0);
if mtype>0 && mtype<35
img = emo{mtype};
else
img = emo{randi(34)};
end
set(h,'CData',img,'FaceColor','texturemap');
end
hold off
axis equal
view([0,0,1])
set(gca,'looseInset',[0 0 0 0])
end
注意:其中的emo.mat
是把b站表情包下载之后,转换为了matlab格式。可以自己制作也可以找我要
%% 散点
x = randi(20,50,1);
y = randi(20,50,1);
figure
emoplot(x,y,'.',0,1),grid on
%% 线
x = 0:0.2:2*pi;
y = sin(x);
figure
emoplot(x,y,'-',18,0.1),grid on
%% 多线
x = 0:0.2:2*pi;
y1 = sin(x);
y2 = sin(x)*2;
y3 = sin(x)+1;
figure
emoplot(x,y1,'-',1,0.1),hold on
emoplot(x,y2,'-',14,0.1),hold on
emoplot(x,y3,'-',25,0.1),grid on
效果如文章开头所示