R How to build angled column headings above columns in heatmap.2: pass (text) plot to the layout?

前端 未结 1 373
长发绾君心
长发绾君心 2020-12-21 23:36

I am very close to the heatmap I want, but I have been struggling for several days to figure out the headings problem. I want angled headings (such as 45 or 50 degrees) at

相关标签:
1条回答
  • 2020-12-22 00:03

    Here's a hack that doesn't involve pulling apart the convoluted code of heatmap.2:

      pos2 <- locator() #will return plotting coordinates after doing this:
      # Shift focus to the graphics window by clicking on an edge 
      # Left-Click once where you want the first label to be centered
      # Left-click again on the point where you want the last label centered
      # Right-Click, then return focus to the console session window
    
     pos2 <- structure(list(x = c(0.27149971320082, 0.858971646016485), 
                            y = c(0.861365598392473, 0.857450478257082)),
                           .Names = c("x", "y"))
    
      text(x=seq(pos2$x[1], pos2$x[2], len=5), y=rep(pos2$y[1],5)  ,
           srt=50, xpd=TRUE, adj = 0,
           labels=c("Sept 2008","March 2010","Sept 2010",
                    "March 2011","Sept 2011") )
    

    I don't know if you actually need the xpd in there, since it appears that after heatmap.2 is finished it returns the window to its native coordinates: [0,1]x[0,1]

    enter image description here

    0 讨论(0)
提交回复
热议问题