Ggplot2: remove color and draw borders on the line chart

I am currently using ggplot2 to build velvet with too many fill levels. As a result, I can’t say when the bar ends and the other starts.

Here is my sample code for what I'm doing right now.

variable<-c("X1","X1","X1","X1","X1","X1","X1","X1","X1","X2","X2","X2","X2","X2","X2","X2","X2","X2","X3","X3","X3","X3","X3","X3","X3","X3","X3")
Length.1<-c(4.24,0.81,0.81,NA,NA,NA,NA,NA,NA,4.24,0.81,0.81,NA,NA,NA,NA,NA,NA,4.24,0.72,0.72,0.16,NA,NA,NA,NA,NA)
data<-data.frame(variable=as.factor(variable),value=as.factor(1:length(variable)),Length.1=Length.1)

## Plots a stacked bar chat in ggplot2 with text labels. Credit to MYaseen208
library(ggplot2)
p <- qplot(variable, Length.1, data = data, geom = "bar", fill = value,     theme_set(theme_bw()))
p + geom_text(aes(label = Length.1), size = 3, hjust = 0.5, vjust = 3, position =     "stack") 

The plot is currently looking great. However, my actual dataset is length(data$value)much higher and I don't see the differences between the different columns as clearly. So, I want to change the colors of the bars to white and draw a black frame around each. Does anyone know how I can do this?

+4
source share
2 answers

ggplot qplot. :

ggplot(data,aes(x=variable, y=Length.1,group=value))+
  geom_bar(fill="white",color="black")+
  geom_text(aes(label = Length.1), size = 3, hjust = 0.5, vjust = 3, position ="stack") +
  theme_bw()
+8
p <- ggplot(aes(variable, Length.1), data = data)+ geom_bar(stat="identity",colour="black", fill="white")+geom_text(...)
0

Source: https://habr.com/ru/post/1524209/


All Articles