שלום,
אני מכינה גרפים באמצעות ggplot2 ויש לי 2 שאלות (בינתיים):
1. אני יוצרת subplot באמצעות :
multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {
require(grid)
# Make a list from the ... arguments and plotlist
plots <- c(list(...), plotlist)
numPlots = length(plots)
# If layout is NULL, then use 'cols' to determine layout
if (is.null(layout)) {
# Make the panel
# ncol: Number of columns of plots
# nrow: Number of rows needed, calculated from # of cols
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols))
}
if (numPlots==1) {
print(plots[[1]])
} else {
# Set up the page
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
# Make each plot, in the correct location
for (i in 1:numPlots) {
# Get the i,j matrix positions of the regions that contain this subplot
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
}
}
}
איך אני יכולה להוסיף כיתוב "A", "B" מחוץ לכל subplot ? (בצד השמאלי העליון)
2. יש גרפים שאני יוצרת מנתונים מקובץ CSV באמצעות:
df <- read.csv('C://figure4b_fixed.csv', header=T)
groups <- levels(df$Group)
df$Group <- factor(df$Group, levels = c(...]))
ggplot(data=df, aes(x = x1, y = y1, col = Group, linetype = Group)) +
+ geom_point(aes(shape=Group), size = 4)
ואז הוא שם ב legend את השמות של הGroup מקובץ ה CSV.
הבעיה היא שאני רוצה לשים שם אותיות יווניות או סימונים אחרים (subscript וכד') שלא קיימים ב CSV. איך אפשר לעשות את זה ?
(נניח, שאם יש Group בשם Alpha אז בתרשים שלי תופיע האות היונית אלפא. או אם יש לי E_K אז ה K יופיע ב subscript.
תודה רבה!
נעה