2017-12-09 12 views
2

gogplot2에서 이모티콘으로 음모를 꾸미려고합니다. 내가 원하는 건 라벨 대신에 그림 이모티콘을 보여 주거나 기러기처럼 보이게하는 것입니다. This question 스택에 내 문제는 매우 비슷하지만 해결되지 않습니다, 대답은 꽤 수동이며 자동 (내 실제 데이터 프레임 3000 행이 있습니다)해야합니다.그림 이모티콘/이모티콘 (ggplot 포함)

아래의 그림에서 명확히하기 위해 텍스트 레이블 대신 또는 이모티콘을 emojis로 표시하려고합니다. 그러나 불가능한 것 같습니다.

enter image description here

differents의 솔루션 내가 쌓여있어 시도 후 그래서 어떤 도움을 주시면 감사하겠습니다. 나는 here, here, here와 같은 문제에 직면하는 여러 가지 방법을 읽었다.

mult_format <- function() { 
    function(x) emo::ji(x) 
} 
ggplot(foo, aes(name_emoji, n)) + 
    geom_bar(stat = "identity") + 
    coord_flip() + 
    scale_y_continuous(labels = mult_format()) 

그러나 그것은 작동하지 않습니다

내 마지막 시도는 다음과 같이이었다.

내 데이터는 다음과 같습니다, name_emoji는 emo package에서 cames, 나는 또한 바이트로 변경할 수 있습니다 여기에

   name_emoji  n  emoji 
        <chr> <int>  <chr> 
1   closed book  1 "\U0001f4d5" 
2   confused face  7 "\U0001f615" 
3     dizzy  20 "\U0001f4ab" 
4 face with tears of joy  1 "\U0001f602" 
5   flexed biceps  1 "\U0001f4aa" 
6    light bulb  1 "\U0001f4a1" 

가 재현 :

structure(list(name_emoji = c("closed book", "confused face", 
"dizzy", "face with tears of joy", "flexed biceps", "light bulb" 
), n = c(1L, 7L, 20L, 1L, 1L, 1L), emoji = c("\U0001f4d5", "\U0001f615", 
"\U0001f4ab", "\U0001f602", "\U0001f4aa", "\U0001f4a1")), .Names = c("name_emoji", 
"n", "emoji"), row.names = c(NA, -6L), class = c("tbl_df", "tbl", 
"data.frame")) 

사전에 감사!

R version 3.4.3 (2017-11-30) 
Platform: x86_64-apple-darwin15.6.0 (64-bit) 
Running under: macOS High Sierra 10.13.1 

Matrix products: default 
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib 

locale: 
[1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8 

attached base packages: 
[1] stats  graphics grDevices utils  datasets 
[6] methods base  

other attached packages: 
[1] emo_0.0.0.9000  emojifont_0.5.1 
[3] DataCombine_0.2.21 forcats_0.2.0  
[5] stringr_1.2.0  dplyr_0.7.4  
[7] purrr_0.2.4  readr_1.1.1  
[9] tidyr_0.7.2  tibble_1.3.4  
[11] ggplot2_2.2.1  tidyverse_1.2.1 

loaded via a namespace (and not attached): 
[1] Rcpp_0.12.14  lubridate_1.7.1  
[3] lattice_0.20-35  twitteR_1.1.9  
[5] sysfonts_0.7.1  assertthat_0.2.0 
[7] digest_0.6.12  psych_1.7.8   
[9] mime_0.5   R6_2.2.2   
[11] cellranger_1.1.0 plyr_1.8.4   
[13] httr_1.3.1   rlang_0.1.4   
[15] lazyeval_0.2.1  readxl_1.0.0  
[17] rstudioapi_0.7  data.table_1.10.4-3 
[19] miniUI_0.1.1  proto_1.0.0   
[21] labeling_0.3  foreign_0.8-69  
[23] bit_1.1-12   munsell_0.4.3  
[25] shiny_1.0.5   broom_0.4.3   
[27] compiler_3.4.3  httpuv_1.3.5  
[29] modelr_0.1.1  pkgconfig_2.0.1  
[31] mnormt_1.5-5  htmltools_0.3.6  
[33] crayon_1.3.4  showtextdb_2.0  
[35] grid_3.4.3   xtable_1.8-2  
[37] nlme_3.1-131  jsonlite_1.5  
[39] gtable_0.2.0  DBI_0.7    
[41] magrittr_1.5  scales_0.5.0  
[43] cli_1.0.0   stringi_1.1.6  
[45] reshape2_1.4.2  bindrcpp_0.2  
[47] xml2_1.1.1   rjson_0.2.15  
[49] tools_3.4.3   showtext_0.5  
[51] bit64_0.9-7   glue_1.2.0   
[53] hms_0.4.0   parallel_3.4.3  
[55] yaml_2.1.15   colorspace_1.3-2 
[57] rvest_0.3.2   bindr_0.1   
[59] haven_1.1.0 

답변

2

: 이것은 내 세션 J_F 및 sessionInfo

foo$name_emoji <- as.factor(foo$name_emoji) 
foo$emoji <- as.factor(foo$emoji) 

ggplot(foo, aes(name_emoji, n)) + 
    geom_bar(stat = "identity") + 
    scale_x_discrete(breaks = foo$name_emoji, labels = foo$emoji) + 
    coord_flip() 

enter image description here

의해 답변을 다음과 같은 출력

편집 (나는 :) 이모티콘을 미워하려고 해요) 나는 다음을 시도했다 :

enter image description here

+0

내게는 효과가 없습니다. 대신에 emojis가 흰색 사각형으로 나타나고, 출력으로 내 질문을 편집합니다. 그리고 내 infosession과 함께 : '( –

+0

당신은 어떻게 얻을 수에 대한 자세한 정보를 제공 할 수 주시겠습니까? 그 RStudio 그 음모가 작동하지 못했습니다.하지만 .svg로 음모를 저장도 제대로 작동하지 않습니다 ... –

+0

내 게시 된 접근 방식은 리눅스 컴퓨터에서 만들어졌지만 윈도우즈에서는 흰색 사각형도 얻었습니다 ... –

1

제공하는 솔루션은 OS에 의존하는 것 때문에, 나는 거친 솔루션 아래에두고 있지만, 경우 누군가에 열려있는 질문을 떠나 솔루션을 제공합니다. 지원에 감사드립니다.

library(gridSVG) 
ps = grid.export("emoji.svg", addClass=T) 

그리고 당신은 ✌️ 얻을 : 이 enter image description here

내가 조정한다고 가정

library(emojifont) 
library(ggplot2) 
load.emojifont("EmojiOne.ttf") 
quartz() 
ggplot(foo, aes(name_emoji, n, label = emoji)) + 
    geom_bar(stat = "identity") + 
    geom_text(family = "EmojiOne", size = 6, vjust = -.5) + 
    scale_x_discrete(breaks = foo$name_emoji, labels = foo$emoji) + 
    theme(axis.title.x=element_blank(), 
     axis.text.x=element_blank(), 
    axis.ticks.x=element_blank()) 

enter image description here 단지 this

당신은이를 사용할 수 있습니다 참조 quartz를 사용하는 데 필요한 수평축에 대한 이모티콘은 수동 솔이 될 수있다. ution하지만 지금은 이모티콘으로 충분합니다.그러나 이전의 솔루션이 리눅스에서 작동하지만 윈도우 나 맥에서 작동하지 않는 이유에 대한 질문이 있으시면