R語言:yyplot畫emoji和動(dòng)物輪廓

導(dǎo)讀

這里記錄兩個(gè)Y叔的繪圖方法??梢援媏moji的R包emojifont,可以畫輪廓的ggimage geom_phylopic函數(shù)。

一、emojifont

emoji庫(kù):https://emojiterra.com/vegetables/
geom_emoji不支持大寫

1 11.25西方感恩節(jié)吃火雞

install.library("emojifont")
library("emojifont")
library("ggplot2")

ggplot() + geom_emoji('turkey', color="steelblue") +
  labs(x="", y="") +
  theme(axis.ticks = element_blank()) +
  theme(axis.text = element_blank()) +
  theme(axis.title = element_blank())

2 玫瑰rose

ggplot() + geom_emoji('rose', color="red") +
  labs(x="", y="") +
  theme(axis.ticks = element_blank()) +
  theme(axis.text = element_blank()) +
  theme(axis.title = element_blank())

3 蘑菇mushroom

ggplot() + geom_emoji('mushroom') +
  labs(x="", y="") +
  theme(axis.ticks = element_blank()) +
  theme(axis.text = element_blank()) +
  theme(axis.title = element_blank())

二、ggimage

1 準(zhǔn)備
USA (IA) 鏡像 + 翻墻 安裝ggimage(無依賴)
HONGKONG 鏡像 + 翻墻 安裝rvcheck (ggimage依賴包)
GUANGZHOU 鏡像 安裝magick (ggimage依賴包)

2 耗子尾汁 rat tail solution

library("magick")
library("rvcheck")
library("ggimage")

options(phylopic_width=128) 

mouse = 'Mus musculus'
id = phylopic_uid(mouse)

d = data.frame(x=0:1, y=0:1)
ggplot(d, aes(x=x, y=y)) + 
  geom_blank() +
  geom_phylopic(aes(image=uid), 
                data=id, 
                x=.5, y=.5, size=.8
                ) +
  geom_phylopic(aes(image=uid), 
             data=id, 
             x=.2, y=.85, size=.3, 
             colour = 'steelblue', angle=180
  ) +
  labs(x=NULL, y=NULL, 
      title='耗子尾汁', 
      subtitle = '做學(xué)術(shù)要講倫理')

3 貓咪

options(phylopic_width=128)  # 抓的是128px的圖,其他數(shù)字報(bào)錯(cuò)哦

sth = 'Felis catus'  # 科學(xué)名
id = phylopic_uid(sth)  # uid對(duì)應(yīng)了相應(yīng)的圖

d = data.frame(x=0:1, y=0:1)
ggplot(d, aes(x=x, y=y)) + 
  geom_blank() +
  geom_phylopic(aes(image=uid), data=id, x=.5, y=.5, size=.4, colour = 'steelblue')

4 火烈鳥

sth = 'Phoenicopteridae'  # 科學(xué)名
id = phylopic_uid(sth)  # uid對(duì)應(yīng)了相應(yīng)的圖

d = data.frame(x=0:1, y=0:1)
ggplot(d, aes(x=x, y=y)) + 
  geom_blank() +
  labs(x="", y="") +
  theme(axis.ticks = element_blank()) +
  theme(axis.text = element_blank()) +
  theme(axis.title = element_blank()) +
  geom_phylopic(aes(image=uid), data=id, x=.5, y=.5, size=.4, colour = 'red')
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容