I am having trouble in adding multiple line text in ggplot. No matter what may I try, it is not working. Either I received an error , or no results at all ,
I got errors Error: Aesthetics must be either length 1 or the same as the data (464): label, group
Error in as.integer(n) :
cannot coerce type 'closure' to vector of type 'integer'
In addition: Warning messages:
1: Only the first value of nrow
will be used.
2: Coercing nrow
to be an integer.
3: In sanitise_dim(nrow) : NAs introduced by coercion
4: nrow
is missing or less than 1 and will be treated as NULL.
5: Coercing ncol
to be an integer.
my tags are
my_tag <- c("Event1 - July 04", "Event2 - July 25", "Event3 - August 10", " Event4 - Sept 28" )
Here is my code
Preinstall1 <- ggplot(PreeventLong, aes(Minutes, value,color = variable, group=variable))+
scale_color_manual(values=c( "grey7", "gray48"))+ ##### for defining desireable colours
geom_blank()+
geom_line(size = 0.8)+
geom_text(aes(x = -Inf, y = Inf, label = my_tag, group = my_tag),
size = 5,
hjust = -0.5,vjust = 1.4,
inherit.aes = FALSE)+
ylab("Flow rate (m3/s)")+
xlab("Time(minutes)")+
theme(legend.title = element_blank(), legend.position = "top",
plot.background = element_rect(NULL), panel.background = element_blank(),
axis.line = element_line())+
facet_wrap(~ Event, scales = "free", label_value(my_tag))+
theme(strip.background = element_rect(fill = "White"),
strip.text = element_text(size = 12, colour = "black", angle = 360))
I want to add more text on multiple lines in individual facet wrap, but failed to do so thus far, some help will be appreciated