2

I have a dataframe in the following long format:

> head(cleanLongPlotData)
  Structure Method Value       Outcome
1      1A00 X1     1    Clustering
2      1A01 X1     1    Clustering
3      1A02 X1     0 No Clustering
4      1A0U X1     1    Clustering
5      1A0Z X1     1    Clustering
6      1A1M X1     0 No Clustering
> tail(cleanLongPlotData)
      Structure     Method Value       Outcome
12931      4PRN       Z        0 No Clustering
12932      4PRP       Z        0 No Clustering
12933      4PXZ       Z       -1         Blank
12934      4PY0       Z       -1         Blank
12935      4Q3H       Z       -1         Blank
12936      6HBW       Z        1    Clustering

Each method has 2,196 observations. I'm plotting it like this:

    p1 <- ggplot(cleanLongPlotData, aes(x=Method, y=Structure,fill=Outcome)) + geom_tile()+
   xlab("Method") +
   ylab("Structure")+
   ggtitle("Cluster Results By Structure")+
      theme(axis.line=element_blank(),
            axis.text.y=element_blank(),axis.ticks=element_blank(),
            panel.background=element_blank(),panel.border=element_blank(),
            panel.grid.major=element_blank(),
            panel.grid.minor=element_blank(),plot.background=element_blank())+
      scale_fill_manual(values = c("#F5F5F5","green","blue"))

I've blocked out the rows because they overlap each other and make a mess. Is there a way to show every 100th row name? Or every 200th row name?

user1357015
  • 11,168
  • 22
  • 66
  • 111
  • `rownames(cleanLongPlotData)[seq(1,nrow(cleanLongPlotData),by=100L)]` etc – MichaelChirico Aug 28 '15 at 19:12
  • @MichaelChirico: That part I get, I'm more curious where I need to save that in order for it to work? – user1357015 Aug 28 '15 at 20:55
  • The y-axis is a factor. Are you saying you want every 100th factor level identified on the y-axis? Will that be meaningful? – jlhoward Aug 28 '15 at 21:02
  • @jlhoward: Yes, the y-axis is just a row for a specific protein structure. By Identifying every 100th structure, it will help reinforce 1) That these are just protein structures with no inherent ordering and 2) The structures are ordered lexicographically as described in my text. – user1357015 Aug 28 '15 at 21:07

1 Answers1

6

Here's an example of displaying every other factor level in an axis. Seems like a really bad idea though...

df <- data.frame(Method=rep(LETTERS[1:10], each=10),
                 Structure=rep(LETTERS[17:26]), 
                 Outcome=sample(letters[1:5],100,replace=TRUE))
library(ggplot2)
ggp <- ggplot(df, aes(Method, Structure))+geom_tile(aes(fill=Outcome))+coord_fixed()
ggp

lvls <- levels(df$Structure)
ggp + scale_y_discrete(breaks=lvls[seq(1,length(lvls),by=2)])

jlhoward
  • 58,004
  • 7
  • 97
  • 140