我正在使用我自己的数据集guide和user_interactions.csv在此weeks.csv之后在彼此内部绘制两个图。但是,我无法正确输出组合图。我已尝试使用 PHPhotoLibrary.sharedPhotoLibrary().performChanges({ () -> Void in
let request = PHAssetCollectionChangeRequest(forAssetCollection: self.assetCollection)
//This is the number of items in my array
println(self.photosAsset.count)
//Only removes the FIRST item, need to remove ALL items
request.removeAssets([self.photosAsset[0]])
}, completionHandler: nil)
和ggsave()
。后者与位置混淆并且通常使得情节更加丑陋。另一方面,pdf()
仅输出最后一个图。如何使用ggsave()
输出这个组合插图?
代码
ggsave
修改
这是使用rm(list=ls())
work_dir <- ".../figures/R"
setwd(work_dir)
dat_weeks <- as.data.frame(read.csv("weeks.csv", sep=";", header=TRUE))
dat_int <- as.data.frame(read.csv("user_interactions.csv", sep=";", header=TRUE))
label_font_theme <- theme(axis.title.x = element_text(face="bold", size=16),
axis.text.x= element_text(size=14),
axis.title.y = element_text(face="bold", size=16, vjust=1.5),
axis.text.y= element_text(size=14))
library(ggplot2)
library(grid)
main_p <- ggplot(dat_weeks, aes(x=week, y=acc)) + geom_line(aes(linetype=type), size=1)
main_p <- main_p + scale_x_continuous(breaks=seq(1,13,1), name='weeks of data')
main_p <- main_p + scale_y_continuous(name='user classification accuracy')
main_p <- main_p + coord_cartesian(xlim = c(1, 13), ylim = c(0.5,0.75))
main_p <- main_p + theme(panel.grid.minor=element_blank())
main_p <- main_p + scale_linetype_manual(name="",breaks=c("HourNet","QuarterNet"), values=c(3,1))
main_p <- main_p + label_font_theme
sub_p <- ggplot(dat_int, aes(x=interactions, y=accurate)) + stat_smooth(lty=1, method = "loess", size=1, colour=c("#000000"))
sub_p <- sub_p + coord_cartesian(xlim = c(0, 2000), ylim = c(0.5,0.75))
sub_p <- sub_p + scale_y_continuous(name='user classification accuracy')
sub_p <- sub_p + label_font_theme
vp <- viewport(width = 0.5, height = 0.5, x = 0.8,
y = unit(3, "lines"), just = c("right","bottom"))
theme_white <- function() {
theme_update(panel.background = element_blank(),
panel.grid.major = element_blank())
}
full <- function() {
theme_white()
print(main_p)
theme_set(theme_bw())
theme_white()
print(sub_p, vp = vp)
theme_set(theme_bw())
}
full()
ggsave("acc_weeks_ggsave.pdf")
的输出。它与原始图不同,因为它例如对于子图有一些奇怪的白色边界。
pdf()