พลิกแกนของ ggplot ไปด้านบนและด้านขวาโดยใช้ธีม ()

ฉันต้องพลิกตัวเลข (และทำเครื่องหมายถูก) ของแกน y และแกน x ไปทางขวาและบนตามลำดับ (แทนที่จะอยู่ที่ตำแหน่งปัจจุบัน) และฉันต้องการให้พวกเขาอยู่ภายในแผนที่ ไม่ใช่ด้านนอก ในที่สุดนี่จะเป็นแผนที่แทรกขนาดเล็ก (โดยไม่มีคีย์หรือช่องว่างสีขาว) บนแผนที่ขนาดใหญ่อีกแผนที่หนึ่ง

แผนที่ของฉันตอนนี้: ป้อนคำอธิบายรูปภาพที่นี่

รหัสของฉัน:

baseInset = get_map(location=c(-160.8,18.5,-154.625,22.5), zoom=8, maptype="terrain")

mapInset<-ggmap(baseInset)

Inset <- mapInset  +
            geom_point(data=CoordInset, aes(x=-Long, y=Lat, fill=Type, shape=Type),
                                            color="black", cex=1.4) + 
            scale_fill_manual(values=c("red", "blue"), 
                              labels=c("Molokaiense (not geo-referenced)",
                                       "Oahuense (not geo-referenced)")) +
            scale_shape_manual(values = c(21,23), 
                               labels=c("Molokaiense (not geo-referenced)",
                                        "Oahuense (not geo-referenced)"))   +
            theme(panel.border = element_rect(fill=NA, colour = "black", size=1),
                 plot.margin = unit(c(0.3, 0.3, -1.7, -0.2), 'lines'), 
                 axis.line = element_blank(), 
                 axis.text.x = element_text(angle=45, hjust=0.9, vjust=2.2, size=8), 
                 axis.ticks.length=unit(-0.15,"cm"), 
                 axis.text.y = element_text(size=8, margin = margin(r = -18)))

ตัวอย่างข้อมูลใน CoordInset:

Long      Lat                           Type

1  155.2000 19.50000             Not geo-referenced
2  155.2000 19.51600             Not geo-referenced
3  155.3433 19.67571             Not geo-referenced
4  155.4000 19.80000             Not geo-referenced
5  155.4483 19.76015             Not geo-referenced
6  155.5000 19.90000             Not geo-referenced
7  155.5000 19.80000             Not geo-referenced
8  155.6000 20.00000             Not geo-referenced
9  155.6000 19.80000             Not geo-referenced

ฉันพยายามเพิ่ม scale_y_continuous(position = "right") และ scale_x_continuous(position = "top") แล้ว แต่ได้รับข้อความแสดงข้อผิดพลาด:

Scale for 'y' is already present. Adding another scale for 'y', which will replace the existing scale.               
Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale.

มีวิธีการทำสิ่งนี้ให้สำเร็จโดยใช้ theme() หรือไม่?

ผลลัพธ์ที่ไม่ดี:

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


person Joseph    schedule 20.06.2019    source แหล่งที่มา
comment
stackoverflow.com/questions/28949001/   -  person M--    schedule 20.06.2019