เพิ่มข้อความที่ไม่ซ้ำให้กับแต่ละด้าน ggplot [ซ้ำกัน]

การใช้ ggplot ฉันกำลังพยายามเพิ่มข้อความที่ไม่ซ้ำกันลงในแต่ละด้านในโครงเรื่องด้านล่างด้วย geom_text แต่ตำแหน่งแนวนอนของข้อความแตกต่างกันในแต่ละด้าน ฉันต้องการให้วางข้อความไว้ที่มุมซ้ายบนของแต่ละด้าน สิบแถวแรกของชุดข้อมูลแสดงอยู่ด้านล่าง ขอขอบคุณล่วงหน้าสำหรับความช่วยเหลือที่ได้รับสำหรับคำถามนี้

FM     x   PC Suitability   Output
1  Max 3.349 71.6         avg 9.20e-06
2  Max 3.997 71.6         avg 9.69e-06
3  Max 4.645 71.6         avg 1.02e-05
4  Max 5.293 71.6         avg 1.08e-05
5  Max 5.941 71.6         avg 1.13e-05
6  Max 6.589 71.6         avg 1.19e-05
7  Max 7.237 71.6         avg 1.26e-05
8  Max 7.885 71.6         avg 1.32e-05
9  Max 8.533 71.6         avg 1.39e-05
10 Max 9.181 71.6         avg 1.47e-05

p = ggplot(y1, aes(x, Output, group=FM, linetype=Suitability, size = 
Suitability)) + geom_line(aes(group=Suitability)) + 
facet_grid(~FM, scales = "free_x", ncol=2)+ scale_linetype_manual(values = 
c("solid","dashed","dashed"))+ scale_size_manual(values=c(.6,.5,.5))+
ylab("Prediction Values\n")+ xlab("\nRange of Values")+ 
theme(axis.text=element_text(size=9))+ theme_bw()+ 
theme(panel.border = element_blank(), axis.line = 
element_line())+theme(legend.position="none")

perc <- ddply(.data=y1, .(FM),summarize, n=paste(PC))
p+geom_text(data=perc, aes(x=.25, y=1,label=n), colour="black", 
inherit.aes=FALSE)

ป้อนคำอธิบายรูปภาพที่นี่


person Andrew Yost    schedule 15.06.2017    source แหล่งที่มา
comment
คุณสามารถจัดเตรียม dataframe ที่จัดระเบียบอย่างเหมาะสมได้หรือไม่   -  person Al14    schedule 15.06.2017
comment
คุณสามารถใช้ x=-Inf แล้วปรับให้เหมาะสมเล็กน้อย .. ลอง geom_text(data=perc, aes(x=-Inf, y=1, label=n), colour="black", inherit.aes=FALSE, hjust = -1)   -  person user20650    schedule 15.06.2017
comment
ใช่! คำตอบนั้นทำงานได้อย่างสมบูรณ์แบบ ... ขอบคุณ ฉันพบวิธีแก้ไขปัญหาอื่นและควรเห็นก่อนที่จะถามคำถาม แต่ป้ายกำกับถูกวางไว้ตรงตำแหน่งที่โค้ดสั่ง ... ที่ค่า x 0.25 และเนื่องจากฉันใช้ scales = free_x ค่า 0.25 จึงแตกต่างกันสำหรับแต่ละด้าน วิธีแก้ไขคือใช้รหัสต่อไปนี้:   -  person Andrew Yost    schedule 16.06.2017
comment
geom_text(data=perc, aes(x=min(y1$x), y=1,label=n), color=black, inherit.aes=FALSE)   -  person Andrew Yost    schedule 16.06.2017
comment
ฉันคิดว่า x= -Inf เป็นตัวเลือกที่ดีกว่า   -  person Andrew Yost    schedule 16.06.2017