Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 20411|回复: 1
打印 上一主题 下一主题

豆粑粑 matlab XKCD风格的图

[复制链接]

529

主题

598

帖子

3014

积分

论坛元老

Rank: 8Rank: 8

积分
3014
跳转到指定楼层
楼主
发表于 2018-6-1 13:26:30 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
XP的论文里,有个comic的图.别人好像是 python,mathematica, latex都画了.matlab 里也有实现, 
https://stackoverflow.com/questi ... le-graphs-in-matlab

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



comic效果的.



  1. clear all
  2. clc
  3. close all



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



  8.   sbp_width=0.7;
  9.   sbp_heig=0.6;
  10.   n_row = 1;
  11.   n_col =1 ;
  12.   [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);
  13.   
  14. %# plot
  15. fh = figure('color','w');
  16. set(fh, 'Position', [100, 100, 600, 550]);
  17. ax=axes('position',out_pos(1,:));
  18. hold on
  19. plot(x,y1,'b','lineWidth',5);
  20. % plot(x,y2,'w','lineWidth',9);
  21. plot(x,y2,'r','lineWidth',4);

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

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

  36. h=gcf;
  37. fi_na = './fig_normal'
  38. fun_work_li_035_myfig_out(h,fi_na,3);
复制代码




函数
  1. function [imt]=fun_mm_xkcd(fh);

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

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

  6. %# make distortion grid
  7. sfc = size(im);
  8. [yy,xx]=ndgrid(1:7:sfc(1),1:7:sfc(2));
  9. pts = [xx(:),yy(:)];
  10. tf = cp2tform(pts+1.2*randn(size(pts)),pts,'lwm',14);
  11. w = warning;
  12. warning off images:inv_lwm:cannotEvaluateTransfAtSomeOutputLocations
  13. imt = imtransform(im,tf);
  14. warning(w)
  15. %
  16. % %# remove padding
  17. imt = imt(16:end-15,16:end-15,:);
  18. %
  19. figure('color','w')
  20. imshow(imt)
复制代码


test_xkcd.m.rar

1.06 KB, 下载次数: 0

fun_mm_xkcd.m.rar

460 Bytes, 下载次数: 0

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-4-20 15:21 , Processed in 0.130945 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表