我正在努力为这个情节创建硬参数。当我用basindf中的更多点填充它时,它最终会推动xlim超出我需要的参数。当发生这种情况时,我尝试在所有函数(map,ggplot,geom_polygon,geom_path)中调整xlim,并且没有任何反应。有什么建议吗?
map.dat <- map_data(map(database= "world", ylim=c(15,90), xlim=c(-180,-24), fill = TRUE))
ggplot(map.dat) +
geom_polygon(aes(x=long, y=lat, group=group, fill=NULL)) +
geom_path(data = basindf, aes(x = latitude, y = longitude, group = factor(id), col = wind)) +
theme(legend.position = "none")
您可以使用这组信息替代basindf。它应该显示问题。
"1128","1957244N15210",1957,"September",1957-09-01,"EP",-149.6,15,25
"1129","1957244N15210",1957,"September",1957-09-01,"EP",-150.5,15,45
"1130","1957244N15210",1957,"September",1957-09-01,"EP",-151.6,15.1,45
"1131","1957244N15210",1957,"September",1957-09-01,"EP",-152.6,15.2,45
"1132","1957244N15210",1957,"September",1957-09-02,"EP",-153.5,15.3,45
"1133","1957244N15210",1957,"September",1957-09-02,"EP",-154.7,15.7,45
"1134","1957244N15210",1957,"September",1957-09-02,"EP",-155.8,16.2,45
"1135","1957244N15210",1957,"September",1957-09-02,"EP",-157,17,45
"1136","1957244N15210",1957,"September",1957-09-03,"EP",-157.8,17.7,45
"1137","1957244N15210",1957,"September",1957-09-03,"EP",-159.1,18.7,45
"1138","1957244N15210",1957,"September",1957-09-03,"EP",-160.3,19.7,45
"1139","1957244N15210",1957,"September",1957-09-03,"EP",-161.7,20.7,45
"1140","1957244N15210",1957,"September",1957-09-04,"EP",-162.9,21.7,75
"1141","1957244N15210",1957,"September",1957-09-04,"EP",-164.4,22,75
"1142","1957244N15210",1957,"September",1957-09-04,"EP",-165.4,23,75
"1143","1957244N15210",1957,"September",1957-09-04,"EP",-166.5,23.8,75
"1144","1957244N15210",1957,"September",1957-09-05,"EP",-167.8,24.4,75
"1145","1957244N15210",1957,"September",1957-09-05,"EP",-168.5,24.6,75
"1146","1957244N15210",1957,"September",1957-09-05,"EP",-169.6,25,75
"1147","1957244N15210",1957,"September",1957-09-05,"EP",-170.5,25,75
"1148","1957244N15210",1957,"September",1957-09-06,"EP",-171.5,25,75
"1149","1957244N15210",1957,"September",1957-09-06,"EP",-172.2,25.1,75
"1150","1957244N15210",1957,"September",1957-09-06,"EP",-172.7,25.3,75
"1151","1957244N15210",1957,"September",1957-09-06,"EP",-173.3,25.4,75
"1152","1957244N15210",1957,"September",1957-09-07,"EP",-173.9,25.3,75
"1153","1957244N15210",1957,"September",1957-09-07,"EP",-174.5,25,75
"1154","1957244N15210",1957,"September",1957-09-07,"EP",-174.9,24.7,75
"1155","1957244N15210",1957,"September",1957-09-07,"EP",-175.4,24.3,75
"1156","1957244N15210",1957,"September",1957-09-08,"EP",-175.8,23.7,75
"1157","1957244N15210",1957,"September",1957-09-08,"EP",-176.2,23,75
"1158","1957244N15210",1957,"September",1957-09-08,"EP",-176.7,22.3,75
"1159","1957244N15210",1957,"September",1957-09-08,"EP",-177.5,21.6,75
"1160","1957244N15210",1957,"September",1957-09-09,"EP",-178.3,21,75
"1161","1957244N15210",1957,"September",1957-09-09,"EP",-179.2,20.5,75
"1162","1957244N15210",1957,"September",1957-09-09,"WP",179.5,19.7,0
"1163","1957244N15210",1957,"September",1957-09-10,"WP",178.3,19.4,0
"1164","1957244N15210",1957,"September",1957-09-10,"WP",177.3,19.8,0
"1165","1957244N15210",1957,"September",1957-09-10,"WP",176.1,20.1,0
"1166","1957244N15210",1957,"September",1957-09-10,"WP",174.8,20.5,0
"1167","1957244N15210",1957,"September",1957-09-11,"WP",173.5,20.9,0
"1168","1957244N15210",1957,"September",1957-09-11,"WP",172.1,21.4,0
"1169","1957244N15210",1957,"September",1957-09-11,"WP",170.9,21.9,0
"1170","1957244N15210",1957,"September",1957-09-11,"WP",169.6,22.5,0
"1171","1957244N15210",1957,"September",1957-09-12,"WP",168.1,23.2,0
"1172","1957244N15210",1957,"September",1957-09-12,"WP",166.7,23.9,0
"1173","1957244N15210",1957,"September",1957-09-12,"WP",165.1,24.5,0
"1174","1957244N15210",1957,"September",1957-09-12,"WP",163.7,25,0
编辑:此地图上的边界是我想要的:
然而,这就是:
编辑#2:当我在它的时候,我怎么把蓝线变成红色?
答案 0 :(得分:1)
正确命名(可能更多)数据会有所帮助,但您肯定可以使用xlim
&amp; ylim
剪辑地图。
library(ggplot2)
map.dat <- map_data(map(database= "world", ylim=c(15,90), xlim=c(-180,-24), fill = TRUE))
basindf <- read.csv("~/Desktop/basindf.csv", stringsAs=FALSE)
gg <- ggplot()
# better way of making a map
gg <- gg + geom_map(data=map.dat, map=map.dat,
aes(x=long, y=lat, map_id=region),
color="black", fill="#eeeeee", size=0.25)
# add your paths
gg <- gg + geom_path(data=basindf,
aes(x=latitude, y=longitude, group=factor(id),
color=wind))
gg <- gg + scale_color_distiller(palette="Reds")
# setup plot/map limits
gg <- gg + xlim(-170, -60)
gg <- gg + ylim(20, 60)
# pick at least some projection
gg <- gg + coord_map("albers", lat0=39, lat1=45)
# map theme - library(ggthemes)
gg <- gg + ggthemes::theme_map()
gg <- gg + theme(legend.position = "none")
gg