簡體   English   中英

R中沒有軸的氣泡圖

[英]Bubble chart without Axis in R

我想在R中創建這樣的圖表: http : //bl.ocks.org/mbostock/4063269

因此,只是一個沒有軸的氣泡圖,氣泡可以隨機分散,並且只能通過size參數來表征。

我對在R中執行此操作很感興趣,因為對我來說,熟悉的選項需要提供x,y和size變量。

這是一種使用bubbles (它基於htmlwidgets因此可以從R控制台,RStudio,R Markdown文檔和Shiny應用程序中使用。):

# devtools::install_github("jcheng5/bubbles")
library(bubbles)

bubbles(value = runif(26), label = LETTERS,
        color = rainbow(26, alpha=NULL)[sample(26)])

這使:

在此處輸入圖片說明


或者,您可以使用packcircles 從文檔中:

功能circleProgressiveLayout通過將每個圓在外部切線與兩個先前放置的圓相切,同時避免重疊,來排列一組以其大小表示的圓。 它改編自Peter Menzel用C語言編寫的版本。

# install.packages("packcircles")
library(packcircles)
library(ggplot2)

p <- circleProgressiveLayout(runif(26))
d <- circleLayoutVertices(p)

ggplot(d, aes(x, y)) + 
  geom_polygon(aes(group = id, fill = id), 
               colour = "black", show.legend = FALSE) +
  geom_text(data = p, aes(x, y), label = LETTERS) +
  scale_fill_distiller(palette = "RdGy") +
  theme_void()

這使:

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM