SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
yurufuwa.R
Package for Cute Graphs!
*・゜・*:.。.  .。.:*・゜今回の⽬目標゜・*:.。.  .。.:*・゜・*  
!
⼥女女⼦子⼒力力の⾼高いグラフを作るためのパッケージを作ろう!  
ついでに
Yurufuwa has no sense of pc!?
ゆるふわ⼥女女⼦子の定義を
発⾒見見!
Default Graphs ≠Yurufuwa
ついでに
イメージ画像
≠
!
yurufuwaplotでプロットしただけ
で可愛いグラフにできたんです!
すごいじゃない,実はパソコン得
意だったの?
そう,パッケージならね!
Package for Cute Graphs!
*・゜・*:.。.  .。.:*・゜今回の⽬目標゜・*:.。.  .。.:*・゜・*  
!
⼥女女⼦子⼒力力の⾼高いグラフを作るためのパッケージを作ろう!  
ついでにグラフを⾊色々いじれるようになろう!  
>  plot(iris[,1],  iris[,2])
Package for Cute Graphs!
>  yurufuwaplot(iris[,1],  iris[,2])        ????
?
Outline!
可愛い画像を埋め込んだりしながらプロットしていく⽅方針  
biOpsパッケージを利利⽤用  
-‐‑‒120もの関数を持つ画像処理理に使えるパッケージ  
-‐‑‒その前にlibjpegがなかったので,installしておきました  
-‐‑‒-‐‑‒www.ijg.orgから最新版の”jpegsr8d.tar.gz”をDownload  &  Install
Outline!
  点  
  飾り  
  フォント?  
  パッケージ
Kawaii = Macaron!?
!
!
まかろんぽ
し”ょしりょくほ°けもん
おもさ  20g
ねた”ん  まちまち
!
し”ょしりょくのしょうちょうとしてあつ
かわれるフランスのおかし.  メレンケ”
にさとうとアーモント”のこなをませ”てや
きあけ”たものか”いっは°んてき.
プロットの点に対応するもの
をマカロンに  
マカロンっぽいものを⾃自分で
描いてみました  
遠⽬目で⾒見見ればマカロンな気も
しなくもない  
⾃自分で焼き上げたマカロンの
画像などがあれば随時変更更で
きるような仕様に
Plot
ぽいもの
>  library(biOps)  
>  img  <-‐‑‒  readJpeg(“macaron.jpg”)  
#このimgはRGBで指定した場合「⾏行行×列列×(r,g,b)」の⾏行行列列なの
で,直接値を変えていくことが可能!  
!
!
!
!
>  plot(img)  
!
#しかもふつうのグラフと同様に描画可能  
#便便利利ですね  
!
>img2  <-‐‑‒  imgMedianShrink(img,  0.3,  0.3)  
!
#適度度なサイズに縮⼩小なんかも楽々です  
#⼤大体プロットの点の⼤大きさになるように縮⼩小します  
!
>img3  <-‐‑‒  imgPadding(img2,  300,  250)  
>plot(img3)  
!
#300×250の画像に変換して確認してみます  
#マカロンに⾒見見えない....  
#....  
>dev.off()  
#⾒見見なかったことにして描画画⾯面をそっと閉じ,次に進みます
!
!
!
!
(255,	
  255,	
  255)
(255,	
  255,	
  255)
(0,	
  0,	
  0)
Scaling Problem
お⽬目当てのプロットになるように,画像を移しては合成し最後
にplotで軸を⾜足すという作業を⽬目論論む  
!
x,y軸の値から画像上の位置を決める⽅方法がわからない  
plot関数の中⾝身をいろいろ覗いてみたがわからず  
!
画像のrgb値を使ってx,yの値に対応するようplot関数を利利⽤用す
ることに
どぅわどぅわ♪  
!
!
!
!
!
!
!
!
!
!
!
>  plot.image  <-‐‑‒  function(x,  y,  imgObj,  xlim,  ylim,  add,  xlab,  ylab,  ssize  =  50,  ...)  
{  
        ix  <-‐‑‒  dim(imgObj)[2];  iy  <-‐‑‒  dim(imgObj)[1]  
        px  <-‐‑‒  1.0/(xlim[1]-‐‑‒xlim[2])/ssize;  py  <-‐‑‒  1.0/(ylim[1]-‐‑‒ylim[2])/ssize  
        for  (i  in  1:iy)  {  
                for  (j  in  1:ix)  {  
                        if  (max(imgObj[i,j,])  ==  255  &&  min(imgObj[i,j,])  ==  255)  next  
                        if  (!add)  {  xlab  <-‐‑‒  "";  ylab  <-‐‑‒  "";  }  
                        plot(c(x+(j-‐‑‒(ix/2.0+1.0))*px),  c(y+(i-‐‑‒(iy/2+1))*py),  
                                col=rgb(imgObj[i,j,1]/255,  imgObj[i,j,2]/255,  imgObj[i,j,3]/255),  
                                xlab=ylab,  ylab=ylab,  main="",  asp=1,  xlim=xlim,  ylim=ylim,  axes=add,  pch=".")  
                        par(new=T,  family="sans")  
                        add  <-‐‑‒  FALSE  
                }  
        }  
}  
#適当
Main Script....
Macaron Plot!
マカロン量量産計画  完了了  
!
!
!
!
!
!
!
!
Font
埋め込みも考えたんですが,⾯面倒だったので今回はパス  
デフォルトパラメータからsansに変更更して出⼒力力  
-‐‑‒-‐‑‒serif,  sans,  mono,  symbolなんかがあります  
!
>  par(family=”sans”)  
!
#⼿手抜き!
Font
>  kirakiraplot()  
!
#グラフ上で適度度に空いている領領域を⾒見見つけてきて,キラキラ画像
をプロットします  
Yurufuwa Colors!
デフォルトのrainbow,   heat.colorsなんかに渡す引数のう
ちのalphaのmaxの値を⼩小さくするだけ!  
!
!
!
!
!
!
!
Yurufuwa Colors!
!
!
!
!
!
!
!
!
!
#もしさらに⾊色のバランスをいじりたかったら...  
>  rgb(1,0,1,1)  
[1]  "#FF00FFFF"  
>  rainbow(10)  
  [1]  "#FF0000FF"  "#FF9900FF"  "#CCFF00FF"  "#33FF00FF"  "#00FF66FF"  "#00FFFFFF"  
  [7]  "#0066FFFF"  "#3300FFFF"  "#CC00FFFF"  "#FF0099FF"  
#この⽂文字列列を2⽂文字ずつ処理理してやればOK!  
#as.hexmode(4278190335),  as.numeric(“0xFF0000FF”)で10進数と16進数の変換も簡単
Packaging!
1. パッケージ作成  
!
!
!
!
!
!
!
9. フォルダの中のDESCRIPTION,  rdファイルを修正  
10. (R  CMD  check)  ←なぜか通らない  
11. 「R  CMD  INSTALL  Yurufuwa」でインストール  
12. library()でロード  
>  ...関数を読み込んでおく...  
>  package.skeleton("Yurufuwa",  c("yurufuwa",    ....),    
                                                            path=filepath)  
Creating  directories  ...  
Creating  DESCRIPTION  ...  
Creating  NAMESPACE  ...  
Creating  Read-‐‑‒and-‐‑‒delete-‐‑‒me  ...  
Saving  functions  and  data  ...  
Making  help  files  ...  
Done.  
Further  steps  are  described  in  '~∼~∼~∼/yurufuwa/Read-‐‑‒and-‐‑‒delete-‐‑‒me'.
省略
!
>  library(Yurufuwa)  
>  yurufuwa(iris[,1],  iris[,2])  
☆大成功☆

Mais conteúdo relacionado

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Yurufuwa@Kashiwa.R.5