我有我設法在ggpot中繪製的小型data.frame。由於ggplot不支持模式,我用顏色繪製數據圖。我會欣賞比我在着色和設計甚至黑白方面做得更好的演示。另外,我無法改變圖例標題ggplot2 barplot
我的數據:
structure(list(Type = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
9L, 8L), .Label = c("Type A+Mod ", "Type B+C+D", "Type E+A",
"Type G+W", "Type H & Mod C", "Type Operation", "Type Production",
"Type Sales", "X, T, S"), class = "factor"), X2011 = structure(c(7L,
4L, 6L, 5L, 9L, 8L, 3L, 1L, 2L), .Label = c("$1,517.00", "$1,579.00",
"$1,727.00", "$105,352.00", "$126,787.00", "$141,647.00", "$187,506.00",
"$24,968", "$30,397.00"), class = "factor"), X2012 = structure(c(7L,
6L, 5L, 4L, 8L, 9L, 3L, 2L, 1L), .Label = c("$1,232.00", "$1,406.00",
"$1,963.00", "$109,533.00", "$125,795.00", "$166,251.00", "$172,238.00",
"$18,040.00", "$23,541.00"), class = "factor"), X2013 = structure(c(8L,
4L, 3L, 2L, 7L, 6L, 5L, 1L, 9L), .Label = c("$1,324.00", "$102,216.00",
"$125,101.00", "$198,769.00", "$2,088.00", "$20,070.00", "$21,094.00",
"$243.91", "$997.00"), class = "factor")), .Names = c("Type",
"X2011", "X2012", "X2013"), class = "data.frame", row.names = c(NA,
-9L))
代碼:
所有的colnames(DF)<-c("Type","2011","2012","2013")
dfMelt<-melt(DF, id.var="Type")
graph<- ggplot(dfMelt,aes(x=Type, y=value))+
geom_bar(aes(fill=variable),stat="identity", position="dodge",linetype=1,colour="red")+
#Tried this for black and white-Seems not working
#scale_colour_grey(start = 0, end = .9) +
theme_bw()+
theme(panel.background = element_rect(fill="grey98"))+
theme(axis.text.x = element_text(angle = 45, hjust = 1))+
theme(axis.title.x=element_text(size=14,face="bold",vjust=-0.2),
axis.title.y=element_text(size=14,face="bold",vjust=0.15))+
theme(axis.ticks.x = element_line(size = 2))+
scale_x_discrete(expand=c(0.01,0))+
scale_y_discrete(expand=c(0.004,0.5))
print(graph)
你需要對你想獲得比「比我在着色方面做了設計,甚至黑白更好地呈現什麼更清晰」。 「更好的介紹」是非常主觀的。 – Henrik
我認爲這個問題很明顯,這就是我得到答案的原因。我試圖得到不同的想法!我把它記下來了。 – SimpleNEasy
首先,我想我已經提供了正在工作的代碼,我沒有毫不費力地問這個問題。正在徵求建議!其次,如果簡單N對你來說很簡單,這並不意味着對其他人來說很容易。 – SimpleNEasy