2

There is a very useful option "ColSideColors" in the native "heatmap" function in R, but how to implement this effect by ggplot2?

As shown in the heatmap, I would like to make the red and blue bar to represent different groups with ggplot2.

Thanks in advance.

enter image description here

ccshao
  • 499
  • 2
  • 8
  • 19
  • possible duplicate of [Reproducing lattice dendrogram graph with ggplot2](http://stackoverflow.com/questions/6673162/reproducing-lattice-dendrogram-graph-with-ggplot2) – Roland May 26 '13 at 15:37

1 Answers1

1

I would say what you are looking for is facetting - in your case you would want to have a factor that distinguishes data entries between the red and the blue part and then have a facet_grid() to split up the graph with respective labels. Say your factor is called subset in the melted dataframe, you would need to add the following to your plot:

facet_grid(. ~ subset)

For further details, have a look at the facet_grid() documentation.

And for an answer that more explicitly addresses your problem, you should describe your problem in more detail. Have a look at some info on how to produce a great reproducible example in R.

Community
  • 1
  • 1
dlaehnemann
  • 671
  • 5
  • 17