豆粑粑 matlab XKCD(comic,漫画)风格的示意图

XP的论文里,有个comic的图.别人好像是 python,mathematica, latex都画了.matlab 里也有实现, 
https://stackoverflow.com/questi ... le-graphs-in-matlab

我自己也玩了一下.效果,还不错.

正常效果的.




fun_mm_xkcd.m

function [imt]=fun_mm_xkcd(fh);

%# capture with export_fig
im = export_fig('-nocrop',fh);

% %# add a bit of border to avoid black edges
im = padarray(im,[30 30 0],255);

%# make distortion grid
sfc = size(im);
[yy,xx]=ndgrid(1:7:sfc(1),1:7:sfc(2));
pts = [xx(:),yy(:)];
tf = cp2tform(pts+1.2*randn(size(pts)),pts,'lwm',14);
w = warning;
warning off images:inv_lwm:cannotEvaluateTransfAtSomeOutputLocations
imt = imtransform(im,tf);
warning(w)
% 
% %# remove padding
imt = imt(16:end-15,16:end-15,:);
% 
figure('color','w')
imshow(imt)



clear all
clc
close all



%# define plot data
x = 1:0.1:10;
y1 = sin(x).*exp(-x/3) + 3;
y2 = 3*exp(-(x-7).^2/2) + 1;



  sbp_width=0.7;
  sbp_heig=0.6;
  n_row = 1;
  n_col =1 ;
  [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);
  
%# plot
fh = figure('color','w');
set(fh, 'Position', [100, 100, 600, 550]);
ax=axes('position',out_pos(1,:));
hold on
plot(x,y1,'b','lineWidth',5);
% plot(x,y2,'w','lineWidth',9);
plot(x,y2,'r','lineWidth',4);

xlim([0.95 10])
ylim([-1 5])
set(gca,'ytick',[-1:1:5])
set(gca,'fontName','Comic Sans MS','fontSize',20,'lineWidth',3)

%# add an annotation 
 annotation(fh,'textarrow',[0.4 0.55],[0.7 0.6],...
     'string',sprintf('text%shere',char(10)),'headStyle','none','lineWidth',1.5,...
     'fontName','Comic Sans MS','fontSize',20,'verticalAlignment','middle','horizontalAlignment','left')
title('I am title')
xlabel(' I am xlabel')
ylabel(' I am ylabel')
legend({'line1','line2'},'location','southeast','box','off')
grid on 
box on

[imt]=fun_mm_xkcd(fh);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值