2
去除邊框我有以下情節:如何刪除從圖例邊框沒有從柱狀圖中GGPLOT2
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)
不具有奇怪的對角線穿過圖例中描繪的方塊。有什麼辦法可以去除那些對角線或刪除對角線?
查看[r食譜網頁](http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/)(最後一個例子)中的示例 –
這是具有完全不同問題的相同數據。我的印象是協議。另外,我不知道在一個小時內詢問4個問題是否有成本。我昨天整天坐在飛機上,想出了一系列我無法解決的問題。 – Atticus29
Didzis Elferts,工作很棒!謝謝! – Atticus29