2

私は次のプロットを持っています:

library(reshape)
library(ggplot2)
library(gridExtra)
require(ggplot2)



data2<-structure(list(IR = structure(c(4L, 3L, 2L, 1L, 4L, 3L, 2L, 1L
), .Label = c("0.13-0.16", "0.17-0.23", "0.24-0.27", "0.28-1"
), class = "factor"), variable = structure(c(1L, 1L, 1L, 1L, 
2L, 2L, 2L, 2L), .Label = c("Real queens", "Simulated individuals"
), class = "factor"), value = c(15L, 11L, 29L, 42L, 0L, 5L, 21L, 
22L), Legend = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("Real queens", 
"Simulated individuals"), class = "factor")), .Names = c("IR", 
"variable", "value", "Legend"), row.names = c(NA, -8L), class = "data.frame")
p <- ggplot(data2, aes(x =factor(IR), y = value, fill = Legend, width=.15))


data3<-structure(list(IR = structure(c(4L, 3L, 2L, 1L, 4L, 3L, 2L, 1L
), .Label = c("0.13-0.16", "0.17-0.23", "0.24-0.27", "0.28-1"
), class = "factor"), variable = structure(c(1L, 1L, 1L, 1L, 
2L, 2L, 2L, 2L), .Label = c("Real queens", "Simulated individuals"
), class = "factor"), value = c(2L, 2L, 6L, 10L, 0L, 1L, 4L, 
4L), Legend = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("Real queens", 
"Simulated individuals"), class = "factor")), .Names = c("IR", 
"variable", "value", "Legend"), row.names = c(NA, -8L), class = "data.frame")
q<- ggplot(data3, aes(x =factor(IR), y = value, fill = Legend, width=.15))


##the plot##
q + geom_bar(position='dodge', colour='black') + ylab('Frequency') + 
        xlab('IR')+scale_fill_grey() +
        theme(axis.text.x=element_text(colour="black"), 
        axis.text.y=element_text(colour="Black"))+ 
        opts(title='', panel.grid.major = theme_blank(),panel.grid.minor = 
        theme_blank(),panel.border = theme_blank(),panel.background = 
        theme_blank(), axis.ticks.x = theme_blank())

黒枠の効果を残したい

geom_bar(colour='black)

凡例に描かれているブロックを横切る奇妙な斜めのダッシュはありません。それらを切り離したり、斜めのダッシュを削除したりする方法はありますか?

4

1 に答える 1

1

Didzis Elferts が述べたように、ここにその例があります(最後の例)。

秘訣は、2 つのプロットを重ね合わせることです。最初のプロットでは、凡例を目的の方法で処理し、2 番目のプロットでは凡例を省略しますが、実際のプロット自体に境界線を追加します。

于 2013-03-25T19:17:21.577 に答える