Buna gerçekten geç kaldığımı biliyorum, ama bence oldukça basit bir çözüm buldum.
floating.pie()(Örneğin arayarak getAnywhere(floating.pie)) kaynak koduna baktığınızda, bunun çok basit ama etkili bir yaklaşım kullandığını göreceksiniz: pasta parçalarını çokgen olarak çizme. Çubuk grafiklerinizden istediğiniz tek şey çubuklarsa (etiket, eksen vb. Yok), aynı yaklaşımı izleyebilir ve kendi işlevinizi yazabilirsiniz. İşte hızlı ve kirli bir sürüm:
# the function
mapbars <- function (x, xllc = 0, yllc = 0, barwidth=1, maxheight=10){
# calculate how long each bar needs to be
bars <- (x/max(x)) * maxheight
# get some quick colors
col <- rainbow(length(x))
for(i in 1:length(x)){
# figure out x- and y coordinates for the corners
leftx <- xllc + ((i-1) * barwidth)
rightx <- leftx + barwidth
bottomy <- yllc
topy <- yllc + bars[i]
# draw the bar
polygon(x=c(leftx, rightx, rightx, leftx, leftx),
y=c(bottomy, bottomy, topy, topy, bottomy),
col=col[i])
}
}
x değerlerin çubuklarla temsil edilmesi içindir
xllcve yllckullandığınız koordinat sisteminde sol çubuğun sol alt köşesinin konumunu belirtin
barwidthve maxheightçubukların boyutunu ölçeklemek için kullanılır
İşte temel sptabanlı bir komplo ile bir demo . Daha önce birlikte çalıştığımı sanmıyorum plotrix, ancak nasıl floating.pieçalıştığına bağlı olarak, bunun da birlikte çalışması gerektiğini varsayacağım plotrix.
library(sp)
library(maptools) # just for easy access to a background map
# load some country borders as a background
data("wrld_simpl")
plot(wrld_simpl)
# zoom on a bit …
mexico <- subset(wrld_simpl, NAME=="Mexico")
plot(mexico, axes=TRUE)
# data for the bars
x1 <- c(4, 7, 1, 2)
# plot
plot(mexico, axes=TRUE)
mapbars(x=x1, xllc=-110, yllc=20, barwidth=.5, maxheight=5)
legend(x="topright", pch=22, col="black", pt.bg=rainbow(x1), legend=c("foo", "bar", "baz", "foobar"))
# add another one:
x2 <- c(9, 21, 64, 45, 33, 43, 12, 7)
mapbars(x=x2, xllc=-100, yllc=25, barwidth=.2, maxheight=2)
Sonuç şuna benzer:

ggsubplotpaketle nasıl yapılacağını da biliyordum , ancak şimdi kullanımdan kaldırıldı ve işe yaramayacak (belirttiğiniz gibi). Belki de bu yazı bir başlangıç noktası olabilir: stackoverflow.com/questions/36063043/…