问题描述
我正在创建一系列与不同区域相关的小线图,然后将其另存为杂项并绘制到欧洲地图上。我可以将其另存为png文件,然后仅使用标准的Windows照片缩放即可放大已保存图像上的部分。但是,这很慢,加载的缩放图像需要花费相当长的时间。我想知道是否有更好的方法,并尝试使用svgPanZoom进行尝试,但是我无法以正确的比例获得被捏住的图,因此它们可见,但是您可以看到轴而不是图本身,而我也无法找出如何保存图解,以便仍然可以平移和缩放。
有人知道更好的方法吗? 我的代码在下面,但数据集太大,无法发布示例。
###species_preds is a list of model prediction dataframes for different 100km squares in Europe
##so dt is a dataframe with a column for julian day,one for prediction and one each for the upper and lower confidence intervals
##list_100km_sp is a dataframe of the x and y centroid locations of all the 100km squares we have prediction
data for
##Europe is a base map,just a filled polygon of Europe
list_plots<-list()
for (g in 1:length(species_preds)){
dt<-species_preds[[g]]
#qualify what's plotted by sample size?
p<-ggplot(data=dt)+
geom_line(aes(x=date,y=round(pred,3),group=1),linetype="solid",size=0.05)+
geom_line(aes(x=date,y=round(u.pred,linetype="dashed",y=round(l.pred,size=0.05)+
xlab("Julian_date")+ylab("Prob of occurrence")+
theme(legend.position = "none",panel.background = element_blank(),panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank(),plot.background = element_blank(),axis.line = element_line(colour = "black",size=0.05),axis.ticks=element_line(size=0.05),text = element_text(size=1),axis.text.x = element_text(angle=90,hjust=1))
list_plots[[g]]<-ggplotGrob(p)
}
##plot all on a map
plot <- Europe + annotation_custom(grob=list_plots[[1]],xmin=list_100km_sp$centroid_x_rounded[1],xmax=list_100km_sp$centroid_x_rounded[1]+130000,ymin=list_100km_sp$centroid_y_rounded[1],ymax=list_100km_sp$centroid_y_rounded[1]+130000)
for (i in 2:length(list_plots)){
plot <- plot + annotation_custom(grob=list_plots[[i]],xmin=list_100km_sp$centroid_x_rounded[i],xmax=list_100km_sp$centroid_x_rounded[i]+130000,ymin=list_100km_sp$centroid_y_rounded[i],ymax=list_100km_sp$centroid_y_rounded[i]+130000)
}
ggsave(plot,file="species.png"),dpi=600,height = 90,width =80,units="cm",pointsize=6)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)