שאלות על גרפיקה ב ggplot2

18 views
Skip to first unread message

noa slater

unread,
Aug 16, 2014, 8:12:46 PM8/16/14
to israel-r-...@googlegroups.com
שלום,

אני מכינה גרפים באמצעות 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.


תודה רבה!

נעה

Jonathan Rosenblatt

unread,
Aug 17, 2014, 3:10:10 AM8/17/14
to israel-r-user-group
אנסה לעזור כמיטב יכולתי, אבל זה רחוק מאוד מאיזור הנוחות שלי.
1) אני לא רואה איזו פונקציונליות של ggplot2 השתמשת. נראה כי את משתמשת ביכולות של grid בלבד, ועל כן השאלה היא איך לשים כיתוב ב- grid (לכך אין לי תשובה).

2) אני מאמין שתמצאי תשובה כאן:


--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jonathan Rosenblatt
www.john-ros.com

Reply all
Reply to author
Forward
0 new messages