我一直在尝试按照给出on a similar Stackoverflow question的建议在ggplot中对各个方面的文本进行注释。但是,我继续收到错误
$<-.data.frame
中的Blockquote错误(*tmp*
,&#34; PANEL&#34;,值= c(1L,1L,1L,1L,:替换有108行,数据有3行 块引用
请查找我的数据here。
创建图表的代码如下:
#read in data
data<-read.csv("CTmax.csv")
#remove superfluent columns
data<-subset(data, select = c(ID, Tank, Rate, Acc_time, Trial_time, CTmax, Age, SL))
#remove control from column "Rate"
data<-data[!(data$Rate=="Control"),]
#change factor structure to numeric
data$Age <- as.numeric(as.character(data$Age))
#plot the trials
plot_AM5<-ggplot(data,aes(x=SL,y=CTmax))+geom_point(aes(shape=Tank,size=1.5,colour=Rate))
plot_AM5<-plot_AM5+theme(legend.position = c(0.9, 0.3), legend.background = element_rect(alpha("white", 0.5)))+
guides(shape = guide_legend(override.aes = list(size = 4)),colour=guide_legend(override.aes = list(size = 4)))
plot_AM5<-plot_AM5+facet_grid(~data$Age,scales="free_x")+coord_cartesian(xlim = c(4, 8))+guides(size=FALSE)
plot_AM5<-plot_AM5 + scale_shape_manual(values = c(0, 1, 15,16))+
scale_colour_manual(values = c("blue", "orange", "red"))+
ylab(expression(paste(CT[max]," (",""*~degree*C, ")", sep="")))+
xlab("Standard length (mm)")+theme_bw()
plot_AM5<-plot_AM5+theme(strip.background = element_rect(colour="black", fill="white"))
plot_AM5
当我现在使用每个方面的示例文本创建一个data.frame并尝试在图表上绘制它时,我遇到了上述错误:
#plot text on individual facets
ann_text <- data.frame(SL = c(7,7,5),CTmax = c(35,33,33),lab = c("Text1","Text2","Text3"),
Age = factor(c(7,14,21),levels = c("7","14","21")))
plot_AM5<-plot_AM5 + geom_text(data = ann_text,label = "lab")
plot_AM5
有人知道我做错了什么吗?提前谢谢!